Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between a parent class and super class

Is there any difference between a parent class and a super class? Is a super class simply a parent class that doesn't inherit from other classes?

like image 542
Zach Latta Avatar asked Oct 24 '12 02:10

Zach Latta


People also ask

What is the difference between superclass and class?

A superclass is the class from which many subclasses can be created. The subclasses inherit the characteristics of a superclass. The superclass is also known as the parent class or base class.

What is the difference between parent class and child class?

Parent class is the class being inherited from, also called base class. Child class is the class that inherits from another class, also called derived class.

Is Super a parent class?

The super keyword refers to superclass (parent) objects. It is used to call superclass methods, and to access the superclass constructor. The most common use of the super keyword is to eliminate the confusion between superclasses and subclasses that have methods with the same name.

Is base class same as super class?

The base class is also called superclass or parent class. The derived class is also called a subclass or child class.


2 Answers

This is more of a terminology difference, the idea of parent and child classes or super and subclasses. It seems to depend on programming language experience and application domain as to which one you use as well as when you first began getting into Object Oriented Programming.

In both cases there is a class, the parent class or super class or base class, from which is derived other classes, the child class or subclass. The child class or subclass extends the parent class or super class by adding some capability to the existing capability of the class being extended.

super() is how the parent or super class constructor for a Java class is invoked in a derived class.

There was a fair amount of churn in the terminology during the first years of object oriented programming as various people worked in the area and published papers and books and developed Object Oriented Languages. It was all quite new and exciting and people were trying to decide the proper vocabulary to use so they were trying out various words and phrases to express Object Oriented concepts.

And with a number of Object Oriented Programming languages that have been developed and gained popularity, a community developed around the language with a particular vocabulary. So older and more experienced programmers who were into object oriented early on may call things a bit different.

Parent and child is also used in describing other kinds of Is-A or Has-A relationships. For instance Parent window and Child window is also used for windowing systems in which a window, the Child, is contained within another window, the Parent. So the Parent window Has-A Child window.

like image 75
Richard Chambers Avatar answered Oct 12 '22 09:10

Richard Chambers


I'd say it's the same.

You might want to differentiate between a direct and indirect parent or super class, but I guess the two terms are not clear enough on this, either. So if this is what you are trying to express, better be explicit.

Also, many programming languages have the "super" keyword used to refer to the (single) direct parent class. But even there, if you call a "super" method and the direct parent does not implement it, it also bubbles up.

like image 26
Thilo Avatar answered Oct 12 '22 09:10

Thilo