This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Wasimullaha an abstract class may or may not have abstract method.but it is not a good programming practice.if you put abstract key word at the class header then your class is taken as abstract.you can't call its constructor.because abstract class means incomplete class.but an abstract class have constrouctor.but you can't call it. its sole purpose & mission is to be extended.so you can't put private access specifier in the abstract method if any.better you go and try it on your machine.
Abstract classes are also used skeletan implementors. Consider the AbstractMap class in the java.util. This class provides implementations of almost all the methods of the Map interface. So in case someday there's any other method in the Map interface. You can override the method in this Class only and the descendants of the abstract class would have method. Though all classes not extending the abstract class would still be broken if they do not override the method. It would only lessen your overhead in such scenarios.
Rajesh Goud kumar
Joined: Nov 29, 2006
I mean whats the use of abstract classes doing this without the method implementation, and use abstract as a key word. why we should do all of this in abstract classes? Using abstract classes how much its useful?
"where it's useful?" - It's all about trying to write software that is maintainable, so you need some kind of flexibility in your design. You know that requirements are going to change and when the project gets into the maintaince phase someone is going to be adding extra functionality or making changes to existing code.
An abstract class is a class that is declared abstract�it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon), like this: