Wednesday, 4 January 2012

Some OOPS Curry

The default access specifier of class is internal and for the class members and methods is private.
Inheritance is accessing the basic class behavior and characteristics and we can also add additional behavior and characteristics in derived class. The two main concepts of inheritance are code reuse and polymorphism.
To create a method that supports polymorphism you need to mark the method in base class using keyword virtual.
Abstract Classes
To require subclasses to implement a method of their base, you need to designate that method as abstract.
An abstract method has no implementation.It creates a method name and signature that must be implemented on all the derived classes.It is not legal to instantiate an object of an abstract class.Once you create a method to be abstract, you prohibit the creation of any instances of that class.If the derived class failed to implement the abstract method, then that class will also become abstract class and no instances of that class is possible.
If one or more methods are abstract then the class definition should also be marked abstract.
eg: abstract public class Window

No comments:

Post a Comment