*
The moose likes Java in General and the fly likes Abstract Class concept Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Abstract Class concept" Watch "Abstract Class concept" New topic
Author

Abstract Class concept

amrut sabade
Ranch Hand

Joined: Aug 16, 2010
Posts: 90
i have some doubt in concept of abstract class. Abstarct class is one which contains altest one abstract function but there can be abstract class which dose not contain a
abstract fuction and contais only concrete methods so why it is called abstract?
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

amrut sabade wrote:i have some doubt in concept of abstract class. Abstarct class is one which contains altest one abstract function but there can be abstract class which dose not contain a
abstract fuction and contais only concrete methods so why it is called abstract?


If there's no abstract method in it- Always better to not call it Abstract. We might not want any instance of that class to be created and so we declare the class as Abstract even though there may not be any abstract method in it.


Mohamed Sanaulla | My Blog
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
A class being declared abstract means that the designer of the class has judged that there should be no instance of that class, only instances of subclasses of that class. That judgement does not depend on whether there are any abstract methods in that class.

Perhaps the class must be subclassed to have any real meaning, but the relevant methods, instead of being abstract, perform no operation. This would allow there to be multiple methods, any one of which need to be implemented by the subclass in order for the object to have a reasonable meaning, but allows the implementor of the subclass to judge which one fits his particular case.

I do not agree that it is "Always better to not call it Abstract." An abstract class has a conceptual meaning; so does an abstract method, but the latter is not required in order to design one of the former.

rc
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Abstract Class concept