1)what is CLR?
CLR is the virtual machine component of Microsoft's .NET framework which is used for memory management and debugging.
CLR is the virtual machine component of Microsoft's .NET framework which is used for memory management and debugging.
2)what is CTS?
CTS is common type system which is used to provide common datatypes for all .net supportable languages.
CTS is common type system which is used to provide common datatypes for all .net supportable languages.
3)what is Nullable datatypes?
Nullable datatypes are used to assign a null value for integer
int? a = null;
Console.WriteLine(a);
Nullable datatypes are introduced from .net 2.0 and above versions
Nullable datatypes are used to assign a null value for integer
int? a = null;
Console.WriteLine(a);
Nullable datatypes are introduced from .net 2.0 and above versions
4)what is the default datatype to store integer value?
int
int
5)what is the default datatype to store decimal value?
double
double
6)what is the Difference between ToString() and Convert.ToString()?
ToString() doesnot handle null values
Convert.ToString()will handle null values.
string s = null;
// string s1 = s.ToString();
string s2 = Convert.ToString(s);
Console.WriteLine(s2);
ToString() doesnot handle null values
Convert.ToString()will handle null values.
string s = null;
// string s1 = s.ToString();
string s2 = Convert.ToString(s);
Console.WriteLine(s2);
7)what is the Difference between int.Parse() and Convert.ToInt32()?
int.Parse() is used to convert string to int
Convert.ToInt32() is used to convert any datatype to int
int.Parse() is used to convert string to int
Convert.ToInt32() is used to convert any datatype to int
8)what is the difference between Valuetype datatype
Value type Reference type
Value type they are stored on stack
Value type store real data .
Value types are faster in access
Value type consists of primitive data types, structures, enumerations.
Value types derive from System.ValueType
Value types can not contain the value null.
========================================================================
Reference type they are stored on heap
Reference type store reference to the data
Reference types are slower in access.
Reference type consists of class, array, interface, delegates
Reference types derive from System.Object
Reference types can contain the value null.
========================================================================
9) what is the checked block and unchecked block?
checked block is used to enable overflow checking for arthimetic and conversion functions.
Ex:- byte b=255;
b++;
C.WL(b);
o/p:- 0 because the range of byte is 0-255 so if the range is exceeded then the value of byte will round to 0 but this type of programming is not safe so if the range of byte is exceeded then runtime error must occur so we have to go for checked block.
checked
{
byte b=255;
b++;
C.WL(b);
}
o/p:- A runtime error will occur saying that
Arithmetic operation resulted in an overflow.
Value type Reference type
Value type they are stored on stack
Value type store real data .
Value types are faster in access
Value type consists of primitive data types, structures, enumerations.
Value types derive from System.ValueType
Value types can not contain the value null.
========================================================================
Reference type they are stored on heap
Reference type store reference to the data
Reference types are slower in access.
Reference type consists of class, array, interface, delegates
Reference types derive from System.Object
Reference types can contain the value null.
========================================================================
9) what is the checked block and unchecked block?
checked block is used to enable overflow checking for arthimetic and conversion functions.
Ex:- byte b=255;
b++;
C.WL(b);
o/p:- 0 because the range of byte is 0-255 so if the range is exceeded then the value of byte will round to 0 but this type of programming is not safe so if the range of byte is exceeded then runtime error must occur so we have to go for checked block.
checked
{
byte b=255;
b++;
C.WL(b);
}
o/p:- A runtime error will occur saying that
Arithmetic operation resulted in an overflow.
10)wap to get the range of byte?
C.WL(byte.MinValue);
C.WL(byte.MaxValue);
C.WL(byte.MinValue);
C.WL(byte.MaxValue);
11)what is the difference between typeOf() and sizeOf()?
typeOf() will get the base(CTS) datatype name
sizeOf() will get the size of the datatype
Console.WriteLine(typeof(byte));
Console.WriteLine(sizeof(byte));
typeOf() will get the base(CTS) datatype name
sizeOf() will get the size of the datatype
Console.WriteLine(typeof(byte));
Console.WriteLine(sizeof(byte));
12. what is the Difference between Boxing and UnBoxing?
Boxing is a process of converting value type datatype to Reference type Datatype
UnBoxing is a process of converting reference type datatype to value type datatype
Boxing is a process of converting value type datatype to Reference type Datatype
UnBoxing is a process of converting reference type datatype to value type datatype
13. what is widening and Narrowing?
widening:- it is a process of converting smaller datatype to longer datatype
Ex:- byte-------int
int---------long
int i=10;
long l;
l=i;
C.WL(l);
Widening does not require Explicit Type casting
Narraowing:- it is a process of converting longer datatype to smaller datatype
Narrowing is unsafe type of programming because the data accuracy is not maintained.
while working with Narrowing we have to do Explicit Type casting
long l=10;
int i;
i=(int)l;
widening:- it is a process of converting smaller datatype to longer datatype
Ex:- byte-------int
int---------long
int i=10;
long l;
l=i;
C.WL(l);
Widening does not require Explicit Type casting
Narraowing:- it is a process of converting longer datatype to smaller datatype
Narrowing is unsafe type of programming because the data accuracy is not maintained.
while working with Narrowing we have to do Explicit Type casting
long l=10;
int i;
i=(int)l;
14)what is the difference between string and stringbuilder?
Both string and StringBuilder are classes.
string is immutable and stringbuilder is mutable
immutable means the value will not change
mutable means the value will change
string will allocate a new memory whenever we concadinate the string value but stringbuilder class will have a method Append() this method is used to insert the new value on the existing value.
so the usage of stringbuilder is more efficient in case of large amount of string
manipulations
if 100% of memory was alocated for a project then98% of memory will be occupied by string
but stringbuilder will occupy nearly 28% of memory so performance wise stringbuilder is more efficient than string
Ex:- string s = "saurav";
Console.WriteLine(s.GetHashCode());
s = s + "Technologies";
Console.WriteLine(s.GetHashCode());
s = s + 10;
Console.WriteLine(s.GetHashCode());
Console.WriteLine("====================");
StringBuilder s1 = new StringBuilder("saurav");
Console.WriteLine(s1.GetHashCode());
s1.Append("technologies");
Console.WriteLine(s1.GetHashCode());
s1.Append("10");
Console.WriteLine(s1.GetHashCode());
Ex for string
class Program
{ static void Main()
{ string x = "";
for (int i = 0; i < 2; i++)
{ x = "saurav" + x;
C.WL(x); C.WL(x.GetHashCode()); } } }
Ex for string Builder
StringBuilder x =new StringBuilder();
for (int i = 0; i < 2; i++)
{ x.Append("sathya" + x);
Console.WriteLine(x);
Console.WriteLine(x.GetHashCode()); }
Both string and StringBuilder are classes.
string is immutable and stringbuilder is mutable
immutable means the value will not change
mutable means the value will change
string will allocate a new memory whenever we concadinate the string value but stringbuilder class will have a method Append() this method is used to insert the new value on the existing value.
so the usage of stringbuilder is more efficient in case of large amount of string
manipulations
if 100% of memory was alocated for a project then98% of memory will be occupied by string
but stringbuilder will occupy nearly 28% of memory so performance wise stringbuilder is more efficient than string
Ex:- string s = "saurav";
Console.WriteLine(s.GetHashCode());
s = s + "Technologies";
Console.WriteLine(s.GetHashCode());
s = s + 10;
Console.WriteLine(s.GetHashCode());
Console.WriteLine("====================");
StringBuilder s1 = new StringBuilder("saurav");
Console.WriteLine(s1.GetHashCode());
s1.Append("technologies");
Console.WriteLine(s1.GetHashCode());
s1.Append("10");
Console.WriteLine(s1.GetHashCode());
Ex for string
class Program
{ static void Main()
{ string x = "";
for (int i = 0; i < 2; i++)
{ x = "saurav" + x;
C.WL(x); C.WL(x.GetHashCode()); } } }
Ex for string Builder
StringBuilder x =new StringBuilder();
for (int i = 0; i < 2; i++)
{ x.Append("sathya" + x);
Console.WriteLine(x);
Console.WriteLine(x.GetHashCode()); }
15)what is an Assembly?
Assembly is the compiled format of any .net program which may be .dll or .exe
Assembly is the compiled format of any .net program which may be .dll or .exe
16)How to view an Assembly?
goto--->start--->MSVS2010---->MSVS2010--->
Visual studio Tools--->
Visualstudiocommandprompt----->ILDASM.exe
IntermediateLangiageDisAssembler
goto--->start--->MSVS2010---->MSVS2010--->
Visual studio Tools--->
Visualstudiocommandprompt----->ILDASM.exe
IntermediateLangiageDisAssembler
17)what is the difference between Private assembly and public assembly?
Private assembly:- The assembly that was specific for a single application is called as
private assembly or folder specific assembly
A seperate copy of dll will be copied in each and every location where we consumed the dll.
Public Assembly: The Assembly that was registered under GAC is called as Public Assembly
while working with public a single copy of dll will be maintained under GAC Location.
Private assembly:- The assembly that was specific for a single application is called as
private assembly or folder specific assembly
A seperate copy of dll will be copied in each and every location where we consumed the dll.
Public Assembly: The Assembly that was registered under GAC is called as Public Assembly
while working with public a single copy of dll will be maintained under GAC Location.
18)what is GAC?
Global Assembly Cache
Global Assembly Cache
19)what is Reflection?
Reflection is used to get the information about an assembly programatically by writing some code
Reflection is used to get the information about an assembly programatically by writing some code
20)How to implement Reflection in .net?
by using System.Reflection
System.Type
by using System.Reflection
System.Type
21)what is satellite assembly?
A satellite assembly is a .NET Framework assembly containing resources specific to a given language. Using satellite assemblies, you can place resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user selects to view the application in that language.
Satellite assembly is used to develop multi lingual applications in .net
A satellite assembly is a .NET Framework assembly containing resources specific to a given language. Using satellite assemblies, you can place resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user selects to view the application in that language.
Satellite assembly is used to develop multi lingual applications in .net
22)what are multilingual applications?
The applications that are build in supportive of more than one human readle language are known as multilingual applications.
The applications that are build in supportive of more than one human readle language are known as multilingual applications.
23)what is the difference betwen
a=b assignin b to a
a==b comparing a with b
a.Equals(b) comparing 2 objects
a=b assignin b to a
a==b comparing a with b
a.Equals(b) comparing 2 objects
24)what is the use of codesnippets?
code snippet is one of the best and easiest way for any developer to increase code productivity simply shortcuts.
code snippet is one of the best and easiest way for any developer to increase code productivity simply shortcuts.
25)what is the difference between Array and collection?
Array
Array is of fixed size
Array is the collection of values of the same data type
Array mainly used to save variables of same data type temporarily until the progarmming in running
>the variables in an array is called array elements
>Array is a reference type data type
ArrayList
-ArrayList is allowed to grow as needed
-Array list are collection of objects of same type or different type.
-Its a Collection of Objects with Sorting Feature.
-Array list is used to store and retrieve the variables of different data type.
-Array list is a class .
Array
Array is of fixed size
Array is the collection of values of the same data type
Array mainly used to save variables of same data type temporarily until the progarmming in running
>the variables in an array is called array elements
>Array is a reference type data type
ArrayList
-ArrayList is allowed to grow as needed
-Array list are collection of objects of same type or different type.
-Its a Collection of Objects with Sorting Feature.
-Array list is used to store and retrieve the variables of different data type.
-Array list is a class .
26) what is a class?
class is a keyword which is used to achieve Encapsulation
class is a userdefined reference type datatype which consits of variables and methods
class is a keyword which is used to achieve Encapsulation
class is a userdefined reference type datatype which consits of variables and methods
27)what is the difference betwee class and structure?
class:-
class is reference type where structure is value type
The memory for the members of the class
will be allocated on heap memory where the memory for the members of structure will be on stack
class supports inheritance but structure doesnot support inheritance
class contains constructors where as structors cannot contain constructors
class:-
class is reference type where structure is value type
The memory for the members of the class
will be allocated on heap memory where the memory for the members of structure will be on stack
class supports inheritance but structure doesnot support inheritance
class contains constructors where as structors cannot contain constructors
28)what is Encapsulation?
29)what is DataAbstraction?
30)what is the constructor?
31)what is the difference between constructor and method?
32)what is the difference between private constructor constructor?
private constructor is used to initialize the values for instance variables
static constructor is used to initialize the values for static variables.
we cannot create an object for the class having private constructor outside the class.
we can create an object for the class have static constructor outside the class.
private constructor is used to initialize the values for instance variables
static constructor is used to initialize the values for static variables.
we cannot create an object for the class having private constructor outside the class.
we can create an object for the class have static constructor outside the class.
33)when the static constructor will be called?
static constructor will be befor ecreating an object the call to the static constructor will be done by CLR
static constructor will be befor ecreating an object the call to the static constructor will be done by CLR
34)can we declare static Accessspecifiers for static constructor ?
No beacuse the call to the static constructor is by CLR
No beacuse the call to the static constructor is by CLR
35) Can we declare parameterised static constructor?
No
No
36)can we override properties?
yes with get accessor
yes with get accessor
37) What is the use of properties?
properties are used to transfer the data
properties are used to transfer the data
38)if we declare Main() and static constructor in same class which one will execute first?
static constructor
static constructor
39)How to call defualt constructor of one class with parametersised constructor of same class?
this()
this()
40)How to call defualt constructor of base class with parametersised constructor of derived class?
base()
base()
41)does C# support multiple inheritance?
No through interfaces we can achieve
No through interfaces we can achieve
42)what is overloading?
43)what is overriding?
44)How to restrict a class from inheritance?
sealed class
sealed class
45)how to stop overrriding?
sealed method
sealed method
46)what is a delegate?
delegate is a type safe function pointer which is used to develop event driven programming.
delegate is a type safe function pointer which is used to develop event driven programming.
47)what is the difference between Event and method?
method will have returntype and event will not have return type
method will have returntype and event will not have return type
48)what are generics?
Generics are general datatype which are used to avoid unnecessary boxing and unbocing and to avoid overloading
Generics are general datatype which are used to avoid unnecessary boxing and unbocing and to avoid overloading
49)Does generics support arthimetic perators?
no
no
50)Can we use Properties in interface?
Yes we can use automatic properties but we have to implement in derived class.
Yes we can use automatic properties but we have to implement in derived class.
Comments
Post a Comment