Sponsored Ad

Tuesday, June 1, 2010

C# - OOPS Interview Questions


Question 1. What is class and objects?

Answer. Class is collection of functions and variables. and object is used to use this template.

Question 2. Can we declare a constructor to private?

Answer. Yes

Question 3. What is the use of constructor ?

Answer. constructor is used to create and instantiate a object.

Question 4. can we specify the accessibility modifier inside the interface?

Answer.  It should be public there is no use of private methods in interface.

Question 5. how to prevent a public class method to be overridden in drive class?

Answer. just make method to sealed.

Question 6. how to stop a class being inherited by another class?

Answer. just make the class sealed. by using sealed keyword.

Question 7.how to prevent a class being instantiated?

Answer. make class abstract or static

Question 8. How to override a private virtual method?

Answer.you can not override a private method.

Question 9.  can you derive a static method of base class in child class?

Answer. no

Question 10.  can you override a normal public method of base class and make it static?

Answer.no , the method signature  should be same to be overridden.

Question 11. what is early and late binding?

Answer. when we call a non virtual method it decide at compile time and this is called early binding. while if method calling decide at runtime is called late binding.

Question 12. Can namespace contain the private class?

Answer. no, having a single private class does not mean anything , it is applicable only in case of nested class.

No comments:

Post a Comment

Sponsored Ad


Follow Us