Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abstract Class concept

 
amrut sabade
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Ralph Cook
Ranch Hand
Posts: 479
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic