YouTube Icon

Interview Questions.

Top 100+ Dot-net Developer Interview Questions And Answers - May 29, 2020

fluid

Top 100+ Dot-net Developer Interview Questions And Answers

Question 1. Briefly Explain The Characteristics Of Reference-kind Variables That Are Supported In The C# Programming Language.?

Answer :

The variables which might be primarily based on reference sorts shop references to the actual data.

The key phrases which can be used to claim reference sorts are:

Class - Refers to the primary constructing block for the applications, which is used to encapsulate variables and methods right into a unmarried unit.
Interface - Contains best the signatures of strategies, houses, events, or indexers.
Delegate - Refers to a reference type that is used to encapsulate a named or nameless technique.
Question 2. Briefly Explain The Characteristics Of Value-kind Variables That Are Supported In The C# Programming Language.?

Answer :

The variables which might be based totally on fee kinds without delay incorporate values.

The characteristics of value-type variables which might be supported in C# programming language are as follows:

All price-type variables derive implicitly from the System.ValueType magnificence
You cannot derive any new kind from a value kind
Value types have an implicit default constructor that initializes the default fee of that type
The cost type consists of two foremost classes:

Structs - Summarizes small corporations of associated variables.
Enumerations - Consists of a set of named constants.
VB.NET Interview Questions
Question 3. Define Variable And Constant.?

Answer :

A variable may be defined as a meaningful call this is given to a records garage region in the laptop reminiscence that carries a cost. Every variable related to a data type determines what form of value may be saved in the variable, for example an integer, which includes 100, a decimal, together with 30.05, or a character, along with 'A'.

You can claim variables by using using the following syntax:

<Data_type> <variable_name> ;

A consistent is just like a variable except that the cost, that you assign to a constant, can not be modified, as in case of a variable. Constants have to be initialized at the equal time they may be declared. You can claim constants by means of the usage of the following syntax:

const int interestRate = 10;

Question 4. Determine The Output Of The Code Snippet.?

Answer :

int a = 29;
a--;
a -= ++a;
Console.WriteLine("The fee of a is: zero", a);

/* The output of the code is -1. */

VB.NET Tutorial
Question five. Differentiate Between Boxing And Unboxing.?

Answer :

When a cost type is converted to an item type, the manner is called boxing; while, while an item kind is transformed to a price kind, the technique is referred to as unboxing. 

Boxing and unboxing permit value types to be handled as gadgets. Boxing a price kind programs it inner an example of the Object reference type. This allows the price kind to be saved on the rubbish accumulated heap. Unboxing extracts the fee type from the item. In this example, the integer variable i is boxed and assigned to item obj.

Example:

int i = 123;
object obj = i; /* Thi line boxes i. */ 
/* The object obj can then be unboxed and assigned to integer variable i: */
i = (int)obj; // unboxing

C#. NET Interview Questions
Question 6. Differentiate Between The While And For Loop In C#.?

Answer :

The whilst and for loops are used to execute the ones units of code that want to be again and again done, except the end result of the specified condition evaluates to false. The handiest distinction among the two is in their syntax. The for loop is distinguished by means of putting an explicit loop variable.

Question 7. Explain Keywords With Example.?

Answer :

Keywords are the ones phrases which might be reserved for use for a selected challenge. These words cannot be used as identifiers. You can't use a keyword to define the call of a variable or approach. Keywords are used in applications to apply the features of item-orientated programming. 

For example, the abstract keyword is used to implement abstraction and the inherits key-word is used to put into effect inheritance by deriving subclasses in C# and Visual Basic, respectively. 

The new keyword is universally utilized in C# and Visual Basic to put into effect encapsulation by using creating items.

C#. NET Tutorial ASP.NET Interview Questions
Question eight. Give The Syntax Of Using The For Loop In C# Code?

Answer :

The syntax of the usage of the for loop in C# code is given as follows: 

for(initializer; situation; loop expression)

 //statements


In the previous syntax, initializer is the preliminary price of the variable, situation is the expression that is checked before the execution of the for loop, and loop expression both increments or decrements the loop counter.

The instance of using the for loop in C# is shown within the following code snippet:

for(int i = 0; i < 5; i++)
 Console.WriteLine("Hello");

In the previous code snippet, the word Hello can be displayed for 5 times within the output window.

Question 9. Give The Syntax Of Using The While Loop In A C# Program.?

Answer :

The syntax of using the even as loop in C# is: 

whilst(condition) //situation

 //statements


You can locate an example of the use of the even as loop in C#: 

int i = 0;
even as(i < five)

 Console.WriteLine("zero ", i);
 i++;


The output of the previous code is: 0 1 2 three 4 .

ADO.Net Interview Questions
Question 10. Mention The Two Major Categories That Distinctly Classify The Variables Of C# Programs.?

Answer :

Variables which might be described in a C# program belong to 2 foremost categories: fee kind and reference type. The variables which are based on price type include a cost that is either allocated on a stack or allocated in-line in a structure. The variables that are based totally on reference types save the reminiscence deal with of a variable, which in turn shops the fee and are allotted at the heap. The variables which are based totally on cost types have their very own replica of facts and consequently operations done on one variable do now not affect other variables. The reference-kind variables reflect the changes made within the referring variables.

Predict the output of the following code phase: 

int x = forty two; 
int y = 12;
int w;
object o;
o = x;
w = y * (int)o; 
Console.WriteLine(w);

/* The output of the code is 504. */

ASP.NET Tutorial
Question 11. What Are The Different Types Of Literals?

Answer :

A literal is a textual illustration of a particular price of a kind.

The one-of-a-kind forms of literals in Visual Basic are:

Boolean Literals - Refers to the True and False literals that map to the proper and false kingdom, respectively.
Integer Literals - Refers to literals that can be decimal (base 10), hexadecimal (base 16), or octal (base 8).
Floating-Point Literals - Refers to an integer literal followed by way of an non-obligatory decimal factor By default, a floating-point literal is of type Double.
String Literals - Refers to a chain of 0 or extra Unicode characters starting and ending with an ASCII double-quote individual.
Character Literals - Represents a single Unicode person of the Char kind.
Date Literals - Represents time expressed as a cost of the Date kind.
Nothing - Refers to a literal that does not have a kind and is convertible to all types within the kind system.
The distinctive sorts of literals in C# are:

Boolean literals - Refers to the True and False literals that map to the proper and false states, respectively.
Integer literals - Refers to literals which might be used to write down values of types int, uint, lengthy, and ulong.
Real literals - Refers to literals which can be used to write down values of types go with the flow, double, and decimal.
Character literals - Represents a unmarried individual that typically includes a individual in quotes, which includes 'a'.
String literals - Refers to thread literals, which can be of two sorts in C#:
A regular string literal consists of zero or greater characters enclosed in double prices, such as "hey".
A verbatim string literal includes the @ person observed with the aid of a double-quote character, inclusive of @"hello".
The Null literal - Represents the null-type.
Question 12. What Does A Break Statement Do In The Switch Statement?

Answer :

The transfer statement is a diffusion manipulate announcement this is used to deal with a couple of choices and transfer control to the case statements inside its body.

The following code snippet indicates an example of the use of the transfer declaration in C#: 

transfer(choice)

 case 1:
 console.WriteLine("First"); 
 damage;
 case 2:
 console.WriteLine("Second");
 ruin;
 default:
 console.WriteLine("Wrong choice");
 break;


In switch statements, the spoil assertion is used on the give up of a case assertion. The smash declaration is mandatory in C# and it avoids the fall via of 1 case assertion to some other.

VB.NET Interview Questions
Question 13. What Is A Data Type? How Many Types Of Data Types Are There In .Internet ?

Answer :

A records kind is a facts garage layout which could comprise a selected kind or range of values. Whenever you declare variables, every variable must be assigned a specific statistics kind. Some common statistics sorts include integers, floating factor, characters, and strings.

The following are the 2 types of information types to be had in .NET:

• Value type - Refers to the statistics kind that carries the statistics. In different words, the exact value or the statistics is directly stored on this data type. It means that whilst you assign a value kind variable to another variable, then it copies the cost rather than copying the reference of that variable. When you create a value kind variable, a single area in memory is allotted to save the cost (stack memory). Primitive data kinds, such as int, float, and char are examples of price kind variables.

• Reference kind - Refers to a records kind that can access statistics by reference. Reference is a cost or an deal with that accesses a particular facts with the aid of deal with, which is stored elsewhere in memory (heap memory). You can say that reference is the bodily address of facts, in which the information is saved in memory or in the storage device. Some built-in reference sorts variables in .Net are string, array, and object.

Question 14. What Is A Parameter? Explain The New Types Of Parameters Introduced In C# 4.0.?

Answer :

A parameter is a unique type of variable, that's used in a feature to offer a chunk of data or input to a caller characteristic. These inputs are referred to as arguments.

In C#, the distinct forms of parameters are as follows:

Value type - Refers that you do no longer want to offer any keyword with a parameter.
Reference kind - Refers which you want to mention the ref key-word with a parameter.
Output kind - Refers that you want to say the out key-word with a parameter.
Optional parameter - Refers to the brand new parameter brought in C# 4.0. It allows you to forget the parameters which have some predefined default values.
The instance of non-obligatory parameter is as follows:

public int Sum(int a, int b, int c = zero, int d = 0); /* c and d is optionally available */
Sum(10, 20); //10 + 20 + zero + 0
Sum(10, 20, 30); //10 + 20 + 30 + zero
Sum(10, 20, 30, 40); //10 + 20 + 30 + 40

• Named parameter - Refers to the new parameter brought in C# four.Zero. Now you can provide arguments via call in preference to position.

The instance of the named parameter is as follows:

public void CreateAccount(string call, string cope with = "unknown", int age = zero);
CreateAccount("Sara", age: 30);
CreateAccount(deal with: "India", call: "Sara");

Question 15. What Is An Identifier?

Answer :

Identifiers are northing but names given to numerous entities uniquely identified in a software. The name of identifiers ought to range in spelling or casing. For example, MyProg and myProg are two exceptional identifiers. Programming languages, together with C# and Visual Basic, strictly restrict the programmers from using any keyword as identifiers. Programmers cannot expand a category whose name is public, because, public is a key-word used to specify the accessibility of facts in programs.

Question sixteen. What Is The Difference Between Constants And Read-most effective Variables That Are Used In Programs?

Answer :

Constants perform the identical responsibilities as examine-simplest variables with a few differences. The differences among constants and read-handiest are

Constants:

Constants are dealt with at bring together-time.
Constants helps fee-type variables.
Constants must be used while it's far not possible that the price will ever exchange.
Read-most effective:

Read-best variables are evaluated at runtime.
Read-simplest variables can preserve reference kind variables.
Read-most effective variables need to be used while run-time calculation is needed.
Question 17. What Is The Main Difference Between Sub-procedure And Function?

Answer :

The sub-system is a block of a couple of visual basic statements within Sub and End Sub statements. It is used to carry out positive tasks, which include changing residences of objects, receiving or processing records, and showing an output. You can define a sub-system everywhere in a software, along with in modules, structures, and lessons.

We can also offer arguments in a sub-method; however, it does now not return a brand new price.

The function is likewise a hard and fast of statements in the Function and End Function statements. It is just like sub-technique and performs the same task. The foremost distinction between a characteristic and a sub-system is that sub-methods do no longer go back a value while capabilities do.

Question 18. What Is The Syntax To Declare A Namespace In .Internet?

Answer :

In .NET, the namespace key-word is used to claim a namespace inside the code.

The syntax for maintaining a namespace in C# is:

namespace UserNameSpace;

The syntax for declaring a namespace in VB is:

Namespace UserNameSpace

C#. NET Interview Questions
Question 19. Which Statement Is Used To Replace Multiple If-else Statements In Code.?

Answer :

In Visual Basic, the Select-Case announcement is used to replace more than one If - Else statements and in C#, the switch-case declaration is used to update a couple of if-else statements.




CFG