• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

abstract

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic