What is the purpose of abstract classes and when are they used?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • renegade109
    New Member
    • Aug 2010
    • 4

    #1

    What is the purpose of abstract classes and when are they used?

    More specifically, say I have classes Animal, Bird, and Parrot...

    Parrot "is-a" Bird
    and
    Bird "is-a" Animal

    I am not given any other information and I have to decide which are superclasses, subclasses, abstract, or concrete (may have multiple answers).

    I know Animal is a superclass and Parrot is a subclass, but what is class Bird? This confuses me because it's caught in the middle so is it both (subclass of Animal, but superclass of Parrot? Or just a subclass?).

    What REALLY confuses me is which ones are abstract or concrete.
    I have no idea when/in-what-situations I am supposed to use abstract classes and all the giberish online is not helping me (that and I left my inclass notes on my school computer in the classroom...). What I mean, is that the online FAQ is not in a very "noob-friendly" language and it merely confuses me further.

    Could someone please tell me in layman's terms when to use superclasses, subclasses, abstract classes, and concrete classes in the example above?
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Animal class is a super class
    Bird class is a child class
    Parrot class is a grand child class.

    There are certain set of functionalities which are in Animal class need to be there in Parrot. Like breathing.

    This link may help you a bit regarding abstract classes.

    If you have any other questions please post back.

    This is a good tutorial to start with.

    Regards
    Dheeraj Joshi

    Comment

    Working...