posted 17 years ago
Dear Reader,
This keyword is used wwhile declaring classes and methods.
For eg.
When used with a class, it does NOT allow any instantiations of it. It means you will not be able to create any object for the above class "MyAbstractClass". This is used when you are not sure about the implementation of the class and the class only gets its real meaning when its extended by some other class.
Absract methods are not given any body. They are only declared.
Note: I have used a semicolon after the method signature.
The body for the method is defined by any class that extends its class.
Here's an example:
You really don't know what an Animal object looks like. Does it have four legs or four horns. There is no definite meaning for it. So you NEED to subclass it to give it a proper shape such as a Dog.
Different Animals have different styles of walking, so we just declare an abstract method for walk() and leave it to the sub-classes to implement a specific style for its class.
Now, there are many rules associated with the "abstract" keyword which you can learn once you understand this concept.
With Best Regards,
Shyam Prasad Murarka