Advanced C# interview Questions and Answers Part 4

1.) How do we inherit from a class in c# ?                                                                               
In c#, we use a colon (:) and then the name of the base class.

2.) Does c# support multiple inheritance  ?                                                                          
No, we use interface for this purpose.

3.) Are private class -label variables inherited ?                                                                
Yes, but it is not accessible.we generally know that they are inherited but not accessible.

4.) What is the implicit name of the parameter that gets passed into class "set" method ?   
Value and it's datatype(it depends whatever variable we are changing).

5.) What is the top .NET class ?                                                                                                   

6.) How does method overloading different from overriding ?                                     
A method overloading simply involves having a method with the same name within the class. whereas in method overriding we can change method behaviour for a derived class.

7.) Can we override private virtual method ?                                                                       

8.) Can we declare the override method static while the original method is non static ?

9.) Can we prevent my class from being inherited and becoming a base class from the other classes  ? 

10.) What is an interface class ?                                                                                                
This is an abstract class with public abstract methods , all of which must be implemented in the inherited classes.

11.) Can we inherit multiple interfaces ?                                                                               

12.) Can we allow class to be inherited ,but prevent the method from being overridden  ? 
Yes, first create class as public and make it's method sealed.

13.) What is signature used for overloaded a method ?                                                  
  • Use different data types
  • Use different number of parameters
  • Use different order of parameters
14.) What is  the difference between an interface and abstract class ?                    
In an interface, all methods must be abstract but in abstract class some methods can be concrete.In interface No accessibility modifiers are alloweded but in abstract class a accessibility modifier are alloweded.

15.) What is different between constructor and method in c# ?                               

More Details...


Post a Comment

Powered by Blogger.