Hi Swapnil Deshpande,
Welcome to JavaRanch!
At first it's not clear why you would ever want to make a class abstract when it has no abstract methods. If all the methods are abstract, you'd use an interface; if some methods are abstract and others are not, you're not given a choice; however, if
no methods are abstract then why make the class abstract at all? Why not just make it a concrete class and allow it to be extended in the normal way, and its methods overridden as required?
The only reason I can think of where this practice makes sense is where the default implementations of the methods in a class provide no useful functionality by themselves, i.e. the class MUST be extended to be of any use. There are examples of this in the
Java 2 Platform.
Consider the java.awt.event.WindowAdapter class: it implements 3 event listener interfaces providing empty implementations of each interface method. The class contains no abstract methods but would be useless if instantiated on its own. The designer/developer therefore declares the class abstract to indicate that it's not intended to be instantiated.
The java.awt.event.WindowAdapter class is provided as a convenience class such that classes wishing to use only one or two methods from the event listener interfaces don't have to create empty implementations of the other interface methods themselves. A concrete class would just extend it and override those methods required. Neat, huh?
I hope that explanation serves to illustrate the value of this rather peculiar type of abstract class.
Jules
[ August 15, 2004: Message edited by: Julian Kennedy ]
[ August 15, 2004: Message edited by: Julian Kennedy ]