OOPS interview questions and answers in C#.Net-part3

61)What is  the difference between String and StringBuilder classes?

  - Both are used to  manipulate and maintain the string
  -each method of the string will return another string object
  -each method of string builder will manipulate with in the same object with out returning another string object

62)What is the advantage of var keyword?


  - it is introduced from C# 3.0
  -It is used to declare the local variables
  -var type of variable must be intialized during the declaration itself.
  -Type of variable will be decided based on its intialization
  -It can not be intialized with null, but it can contain the reference of object
  -var type of variable can not be passed as a parameter to the method.

63)Can we assign null to var type of variable?


 --No

64)Can u allow class to be inherited,but method must be prevented from being overridden?


65)What is the difference between abstract method and virtual method?

abstract method                                                       virtual method
-Abstract Keyword must be used                          -virtual keyword must be used
-It should not have defination in the base class     -It must have the defination in the base class
-It must be overridden in the derived classes         -It may or may not be in the derived classes
-It must be with in the abstract class                      -It can be with in the         abstract and non abstract classes

66)Can we define virtual method as private member?


   -No

67)Can we define abstract method as private member?


  -No

68)Can we define abstract method as static?


-No

69)Can we declare private class in namespace?


-No, members of the namespace must be either internal or public

70)What is the difference between new and override keywords?

- New is used to create the object dynamically
  -Override key word is used to override either virtual or abstract methods

 

71)Can we Create object with out defining class?


  -Yes, we can create an object by usinf new operator with some intialization.
  -Based on intialization approriate annonomous type will be defined by the compiler.

72)What is the purpose of this?

  -it is a predefined reference variable which contain the reference of a current object or active object.
  - when the names of the parameters and instance variable names are same then instance variables can be differentiated from the parameters by
   using this keyword.
  -This can be used with instance methods only.

73)What is the difference between Array and ArrayList?

      Array                                                        ArrayList
-it is typed collection                                  -it is untyped collection
-fixed size                                                    -size will be increased dynamically.
-boxing and unboxing not needed               -extra burden of boxing and unboxing.

74)What is difference between List and ArrayList?

   List                                                           ArrayList
-it is generic collection                              -it is non genaric collection
-boxing and unboxing is not needed          -Extra burden of boxing and unboxing
-size will be inbcreased dynamically        -size will be increased dynamically


75)What is the diffference between Hashtable and SortedList?

-both the collections are defined as Dictionaries where in elements are stored in the form of (key,value) pair,but in sortedList values are 
maintained according to   keys in ascending order.

76)What is assembly?

     -it is language independent,self described portable software component.

77)Is IL language is OO?

    -no

78)What are different types of assemblies?

     -there are three types of assemblies
 a)private assembly
  -an assembly with out strong name key is called as private assembly
  -when private assembly is used in application,then copy of it will be available as part of application.so that memory will be wasted when too many application are running at a time.
 -if some changes are made in assembly then they are not reflected to application until its compilation.
b)public or shared assembly
-an assembly with strong name key and placed in GAC is called as shared assembly or public assembly.
   -Advantages:
 -no memory wastage if even too many application using same assembly  are running.
 -if some changes are made to assebly then those changes are automatically reflected to application with out recompilation
     
c)satilite asembly
 -it is private or public assembly with resource file.
  -it is used while creating assembly for multi linguistic purpose.

79)What is digital signature of an assembly?

  -it is combination of private key and hash algorithem value of aseembly.
   -digital signature of an assembly will be checked while installing it into GAC.

80)What is PE file?

  -an assembly with win32 header is called as PE file
  -it is microprocessor independent.

81)What is ilasm.exe?

-it is a tool which is used to convert assembly into PE file.

82)What is ILDASM.exe?

 -it is also a tool which is used to see the content of assemby in text format.

83)What are advantages of genarics?

     -Boxing and unboxing burden can be reduced while working with collections.
     -Code burden on developer can be reduced.

84)What is boxing and unboxing?

     -Converting value type into reference type is called as boxing.
     -During boxing type casting will be done implicitly
    -Converting reference type to value type is called as unboxing
    -during unboxing type casting must be done explicitly




 85)What are the disadvantages of boxing and unboxing?

     -During boxing and unboxing values must be copied from method stack to managed heap and viceversa.
     -During unboxing if typecasting is not done properly then it will raise exception called InvalistCastException.

86)What is delegate?

     -it is reference type which represents method.
     -delegate object can contain reference of method
    -with the help of delegate object we can invoke a method dynamically based on its reference.

87)What are different types of delegates?

     there are two types of delegates
     a)single cast delegate:
            -if delegate object contains only one method reference then it is called as single cast delegate.
    b)multi cast delegate:
        -if delegate object contains more than one method reference then it is called as multicast delegate.
       -with the help of multicast delegate we can invoke multiple methods sequentially  with single call.

88)What is lambda expression?


      -representing  complete method defination with the help of simple expression is called as lambda expression

89)What are diiferent types of lambda expressions?

     -there are two types of lambda expressions
 a)predicate:            

    A lambda expression which is designed to return either true or false is called predicate
  b)projection:       

   A lambda expression which is designed to return other than true or false is called projection.

90)What is Annynomous method?

   A method which is assumed by the compiler based on the defination of the delegate and defination of the method given by developer 
is called as annynomous method.

For Part-2   click here
For Part-4   click here

Thanks for visiting this blog. How is the content?. Your comment is great gift to my work. Cheers.

No comments:

Post a Comment