Monday, May 10, 2010

cool stuffs from OOPS

1) Do private members of the BASE class are derived by the child class?
Ans: Yes they are derived but are not accessible in child class. Public/Private/Protected are used for achieving access level rights.
2) What are the three things that comes to your mind when you think about OOPS?
Ans: Inheritance, Polymorphism, Abstraction/Encapsulation
3) Why C# doesn't support multiple Inheritance?
Ans: A known problem called "Diamond of Death" will occur if one class will extends multiple classes and the base classes might have derived from a single base class.
But in some other way it seems it is supporting.
i) For example a class can implements multiple Interfaces.
ii) More appropriate example will be an Interface can implement more than one Interface.
4) interfaces do not provide a default implementation
5) What are the ways by which you can make sure that a class can not be inherited by other classes.
Ans: i) make it sealed (C#)
ii) Declare the constructor as private.
6) What are accessor and mutator?
Ans: Accessor and Mutator helps in achieving Encapsulation.An accessor is a method that provide info on object. They are genrally properties which have a get method.On the other side Mutators can modify an object's state. They are the set method in a properties.

Keep watching this space for some extra innings from OOPS.

1 comment: