Difference Between a Parent Class and Super Class

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?

5 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.

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.

0

They are different terms to address the same OOP concept: inheritance. If class ChildClass extends ParentClass you can say:

  • ChildClass parent class is ParentClass
  • ParentClass is the super-class of ChildClass

Inheritance levels have nothing to do there, it doesn't matter if a Super-Class itself extends another class.

They are essentially the same. Depending on the language, the terminology changes. Parent may mean the immediate parent, while Super class may mean any of the ancestor classes. In addition, in java, there is the super() method, which calls the parent's constructor.

In Ruby language we have both the concepts meaning different things.

ParentClass -> ChildClass -> this is used for namespacing

and

SuperClass -> SubClass -> this is used for inheritance

Examples below:

ParentClass -> ChildClass:

class A
  def self.f1
    puts "A -> #{self.name}.f1 called"
  end
  # B is childclass of A
  class B
    def self.f2
      puts "B -> #{self.name}.f2 called"
    end
  end
end

# C is subclass of A
class C < A
  def self.f3
    puts "C -> #{self.name}.f3 called"
    B.f2
  end
end

See the output below:

  1. C.f1

A -> C.f1 called

  1. C.f3

C -> C.f3 called

B -> A::B.f2 called

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett
Author

Chloe Bennett

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.