• Post Reply Bookmark Topic Watch Topic
  • New Topic

abstract  RSS feed

 
YingShiuan Chang
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a class, if one of methods is abstract, the class must be declared for abstract. An abstract class can't produce instance objects. Thus,how to use the other methods that is not abstrcat? Is it the same as the abstract method that can be used by the subclass that extends the class?

Thanks.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. The member methods of an abstract class can only be called on an instance of a concrete subclass. That's really the whole point of abstract classes: an abstract class is "incomplete" and needs to be "finished" by subclassing before it can be used.

Most of the time, when people ask questions like this, it's because they're thinking about how they program in a non-object-oriented language. If you look at it that way, then the fact that "you can't call the functions of an abtract class" just seems dumb. But once you're used to object orientation, you won't think about it this way any more; your goal won't be to find a function you can call, but to find an object you can send messages to. Once you start thinking in this new way, abstract classes make perfect sense.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!