November 27, 2020

Dotnet Interview Questions

Dotnet Interview Questions and Answers

1Q.What is .Net Framework?Ans:

  • NET Framework is an important integral component in .NET software.
  • .NetFramework is a runtime environment,which we can use to run .net applications.

2Q.What is Visual Studio.Net?Ans:Visual Studio .NET online training is a Microsoft-integrated development environment (IDE) that can be used for developing console applications, Windows Applications, Web Applications, Windows Service, Web service.. And so on.

3Q. Difference between .Net Framework and VisualStudio.Net?Ans:


1. It is a run- time environment, which 1. It is a development environment, we can use to run applications. which we can use to develop applications.

2. It is required for .net developers and 2. It is required for only .net developers. .net application end users

3. It is a free ware which we can 3. It is not free way which we have to download from Microsoft Website. purchase from Microsoft.

4Q. What is CLR?

  • Ans: CLRstands forCommon Language Runtime, it is .net execution.
  • CLR is a common execution engine for all .NET Languages that means every .NET language application has to execute with the help of CLR.

5Q.Explain .net application Execution process?Ans:.Net application Execution process can be divided into 2 steps:Step1.Converting HIGH level language code into MSIL (Microsoft Intermediate Language) with the help of language compilers because .Net execution engine (CLR) can understand only MSIL code.Step2.JIT (JUST-IN-TIME) compiler will convert MSIL code to NATIVE code because operating system can understand only NATIVE code or MACHINE code.

6Q.What is JIT Compiler?Ans:JIT (JUST-IN-TIME) Compiler will convert MSIL (Microsoft Intermediate Language) code to Native code because operating system can understand only Native code or machine code.

7Q.What is CLS?

  1. CLS (Common Language Specifications) is a set of common language standard defined by the Microsoft for all .NET Languages.
  2. Every .NET Language has to follow CLS Standards.
  3. Whenever a Programming Language wants to recognize as dot net training Language then it has to follow CLS.

8Q.What is CTS?Ans:

  • CTS (Common Type System) is a subset of CLS. It is a set of common based data types defined by Microsoft for all .NET Languages.
  • Every .NET Language has to map their data types with CTS types.

9Q.What is MSIL Code?Ans:Microsoft Intermediate Language (MSIL), is one of the Core component of the .NET Framework. Any .NET source codes written in any .net supportive language (C#, etc), when compiled are converted to MSIL. This MSIL, when installed or at the Runtime, gets converted to machine code. The Runtime conversion of MSIL code to the machine code is handled by a component called as the Just In Time (JIT) Compiler.10Q.Explain the role of Garbage collector?Ans:In .NET, MEMORY MANAGEMENT is handling by GARBAGE COLLECTOR (GC). GC is an integral part of CLR. To perform memory Management GC will do 2 duties. 1.Allocating the Memory->When new object is created by application garbage collector will allocate memory for that object with in Managed heap.

  1. De-Allocating the Memory:-

->When an object is not using by the application garbage collector will recognize it as unused object..and garbage collector will destroy unused objects according to generation algorithm.

11Q.What is Managed Code and Unmanaged Code?.Net application may contain 2 types of codes.

  1. A) Managed CodeB) Unmanaged Code

Ans: Managed code:The code which is taking the help of CLR for execution is called as managed code. Example for Managed Code:- All .net languages code is managed code. VB.Net code, C#.Net code…etc

  1. Unmanaged code: -

The code which is not taking the help of CLR for execution is called as Unmanaged code.. Example for Unmanaged Code:- In .net application non .net code is unmanaged code.. VB Code, VC++ Code.

Note: - .net application can contain non .net code.


12Q.Why C#.Net?Ans:To develop any type of application by using .NET we require one .NET LANGUAGE to write the business logic of that application.

13Q.Explain about primitive data types?Ans:In C#.NET, according to the type of the data and size of the data, data types are classified into5 types. They are—

  1. Numerical Data typesSigned Numerical data types:

sbyte, short, int, long b.Unsigned Numerical data types;-byte, ushort, uint, ulong 2.Floatingfloat, double, decimal 3.Character related Data typesa) Char 4.Logical Data Typesa) bool

  1. General data Typesstring
  2. object

These data types are called as dot net online course PRIMITIVE DATA TYPES.

14Q.What is the MaxValue and MinValue?

Ans:MaxValue and MinValue are predefined constants, which are members of every primitive data type structure except bool. Using this Constant we can get the MINIMUM value and MAXIMUM value of a data type.

15Q.Difference between value types and Reference types?


1.In value types, data will storing in 1. In this, Data will be storing in HEAP STACK MEMORY MEMORY.

2. Value type variable can contain the 2. Reference type variable will contain actual data. the address of the data.

3. In primitive data types except General 3. In primitive data types only General data types are called VALUE TYPES. data types will come under They are Numerical, Floating, Character REFERENCE TYPE. and Logical. Ex: Int, Long, Char EX: String, Object

4. Structures and Enums are value types 4. Class, interface, delegates come under this.

16Q.When we will go for signed data types and when we will go for unsigned data types?

For Example:-When we will go for sbyte When we will go for byteAns:Whenever we want to allow both positive and negative values then we will go for signed data types. Whenever we want to allow only positive values then we will go for unsigned data types. Here sbtye is a signed data type and byte is an unsigned data type.

17Q.What is the output?static void Main (string args) { Char c='a'; int j=c; Console.WriteLine (j); Console.ReadLine ();}Output: 97

18Q.Can I assign 1 or 0 into bool variable?static void Main(string args) { bool b = 1; Console.WriteLine(b); Console.ReadLine(); } Ans: No

19Q.What is the output ?static void Main(string args) { bool b = true; Console.WriteLine(b); Console.ReadLine(); }OUTPUT:True

20Q.Can we assign null value into value type variable?Ans: No. but we can assign null values into reference type variable.

21Q.How to assign null value into value type variable?Ans:We have to go for NULLABLE VALUE TYPES. Syntax: ? =NULL;

22Q.When we will declare particular variable as nullable type?Ans: Whenever an input is an optional that means not compulsory then we can declare particular variable as NULLABLE TYPES.

23Q.What is implicit typed variable when we will go for implicit typed variable?Ans:

  • Usingvarkeyword we can declare IMPLICIT TYPED VARIABLE.
  • IMPLICIT TYPED VARIABLE can have any data type value and this variable will be converting into particular data type based on the value

which is assigning. Whenever we r unable to expect the type of value which is going to assign.

24Q.What is the difference between GetType() and typeof()?

Ans: typeof() GetType() 1. It will return the given data type

1. It will return the given variable base type data type base type 2. It is a operator 2. It is a method

25Q.What is the output?static void Main(string args) { var a = 10; var b = 10.5; Console.WriteLine(a.GetType()); Console.WriteLine(b.GetType()); Console.ReadLine(); }OUTPUT: System.Int32System .Double

26Q.What is implicit type casting? When we will go for explicit type casing?Ans: IMPLICIT TYPE CASTING: -Converting from Smaller size data type to bigger size data type is called as IMPLICIT TYPE CASTING.When EXPLICIT TYPE CASTING:- The type casting which is not possible by using implicit type casting then we have to go for EXPLICIT TYPE CASTING.

27Q.Difference between Parsing and Converting?

Parsing Converting 1. Using parsing we can convert from 2. Using converting we can convert only string data type to any other data from any data type to any other type except object data type. data type.

28Q.What is the output?static void Main(string args) { string s1 = "1234"; string s2 = "1234.5"; string s3 = "rama"; string s4 = null; string s5 = "12321321321323232132132332"; int res; res = int.Parse(s1); Console.WriteLine(s1); //res = int.Parse(s2); //res = int.Parse(s3); //res = int.Parse(s4); //res = int.Parse(s5); Console.ReadLine(); }OUTPUT: 123428Q.Difference between int.Parse() and Convert.Toint32()?Ans:

Int.Parse() Convert.ToInt32() 1.Using this we can convert from only 1.Using this we can convert from any STRING to INT. data type value into INT. 2.When we are parsing if the string 2.When we are converting if the string variable contains NULL value then this variable contains NULL value then it parsing technique will throw argument will convert that NULL as ZERO. NULL EXCEPTION.

29Q.What is Boxing and Unboxing?

Ans:BOXING: -It is the process of converting from VALUE type to REFERENCE type.UNBOXING: -It is the process of converting from REFERENCE type to VALUE type. EX: converting from object to int.

30Q.What is the difference between Convert.ToString() and Tostring()?

Ans:Convert.ToString() handles NULL values even if variable value become NULL. Tostring() will not handles NULL values it will throw a NULL reference exception error.

31Q.What is the difference between string and StringBuilder?

Ans:STRING STRING BUILDER 1. When we implement modifications to 1. When we implement modifications to the existing String object within the existing StringBuilder object will not memory it will create a new object. create new copy of object instead of that Because string is IMMUTABLE. it will modify the existing object. Because StringBuilder is MUTABLE. 2. String will allocate a new memory 2. StringBuilder class will have a whenever we concatenate the string method Append() this method is used to Value insert the new value on the existing value. EX: String s1=‖sathya‖; so the usage of string builder is more S1=s1+‖Tech‖; efficient in case of large amount of Console.WriteLine(s1); string EX: StringBuilder s1=new StringBuilder(―sathya‖); S1.Append(―Tech‖); Console.WriteLine(s1); 3. It will occupy more memory, it will 3. It will occupy less memory, it will decrease the performance of improve the performance of applications. applications. For Example:- static void Main(string args) { string s1 = "Hydera"; Console.WriteLine(s1.GetHashCode()); s1 = s1 + "bad"; Console.WriteLine(s1.GetHashCode()); Console.WriteLine(s1); StringBuilder s2 = new StringBuilder("Hydera"); Console.WriteLine(s2.GetHashCode()); s2.Append("Bad"); Console.WriteLine(s2.GetHashCode()); Console.ReadLine(); }

32Q.What is Error, Bug and Defect?

Ans:Error--> Which comes at the time of development.Bug--> Which comes at the time of testing. (Pre-Release)Defect--> Which comes in Production. (Post-Release)

33Q.Why class and object?

Ans:CLASS:To achieve ENCAPSULATION, as well as for modularityOBJECT:To allocate memory for instance variables & to store the address of instance method.

34Q.When we will go for instance variable?

Ans:Whenever we required a filed for multiple objects with the different values, then particular variable we will declare as INSTANCE VARAIBLE.

35Q.When we will go for static variable?

Ans:According to the requirement whenever the value is common for all the objects then particular variable will declared as STATIC.

36Q.Difference between instance variable and static variable?

Ans:INSTANCE VARIABLE STATIC VARIABLE (or) (or) NON-STATIC VARIABLE CLASS VARIABLE 1. A variable which is declared within 1. A variable which is declared inside the class and outside the method the class and outside the method by WITHOUT using STATIC keyword is using STATIC keyword is called as called as INSTANCE VARIABLE. STATIC VARIABLE. 2. Instance variable will create multiple 2. Static variable will create only once times for every object creation. when the class is loading. 3. Instance variable value will be 3.satic variable value will be same for differs from one object to another every object object.

37Q.When we will go for readonly?

Ans:Whenever filed is required for every object with the different value, but the value not required change.

Ex: - EmpNo

38Q.When we will go for static readonly? Difference between static variable and static read only?

Ans:Whenever we want to have common value for every object and value should not be changed forever we will go for static readonly.

STATIC VARIABLE STATIC READONLY 1. Value will be common for all objects 1. value be common for all objects but but value can be changed value can’t be changed

39Q.Difference between constant, static and read-only?

Ans:CONSTANT STATIC VARIABLE READONLY 1.const keyword is used 1. static keyword

1.Readonly keyword

2. Its value cannot be 2. Its value can be 2.Its value cannot be changed changed modified

3. By default constant is 3. For static variable, 3.By default Non-static static that means we don’t programmer has to require to use any static declare as static keyword 4. Constant value should

4. Static variable can be 4. Readonly can be be initialized at the time initialized at the time of initialized at the time of of declaration which we declaration as well as we declaration or runtime cannot initialize in can initialize in runtime (only within the runtime. within the static constructor) constructor.

40Q.When the memory will be allocated for instance variable and static variable?Ans: STATIC VARIABLE: - At the time of class is loading, memory will be allocated for static variable.INSTANCE VARIABLE: - When the object is created the memory is allocated for instance variable dot net training online india.



net training

dot net course

dotnet institute

.net online training hyderabad

.net online training india