Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrendan Whiting
Front End Web Development Techdegree Graduate 84,735 PointsSubclass/superclass/base class - I'm confused
I'm confused. If we're thinking about inheritance visually, is the "original" on the top or on the bottom? Is a base class the same as a super class?
2 Answers
Grigorij Schleifer
10,365 PointsHi Brendan,
In an OOP language, the base class is a class from which other classes are derived from.
The top-most "base" class, the class from which all other classes are derived, is the Object class defined in java.lang. Object is the root/base of a hierarchy of classes but in many illustrations you will see the Object class shown above of all classes at the top.
General the class that is derived from another class is called a subclass. The class from which it's derived is called the superclass. So the subclass is "under" the superclass. So the father of all superclasses is the Object class.
Grigorij
Rob B
11,677 PointsThink of it like this: Base Class is the Parent. a Subclass is the Child. Think of it just like family lines. You might have "Grandparents", or even "Great Grandedchildren"
Just like with genetics, certain things are inherited. What this really breaks down to is that by declaring variables, modules/methods/functions, and so on in a Base Class, the Subclass doesn't have to re-declare any of those if you still want to use them.