What is the super class of every class in Java?

Java 8Object Oriented ProgrammingProgramming

The class named Object is the super class of every class in Java.

Let’s test it with an example. The java.lang.Class.getSuperclass() returns the Class representing the superclass of the entity (class, interface, primitive type or void) represented by this Class.

So, Create a sample concrete class and lets try to get the name of its super class using this method.


Live Demo

public class Test {
   public static void main(String args[]){
      Test obj = new Test();
      Class cls = obj.getClass().getSuperclass();


Since the Object class is the super class of all classes it displays the name of the object class as shown below.

Published on 08-Jan-2018 05:05:36