In this tutorial we are going to learn , how to get all super classes of a class . To get super class of a class , getSuperclass() method was provided in in java.lang.Class. See the below example.

package com.java;
class B{
}
class A extends B{
}
public class Sample extends A {
    public static void main(String[] args) throws ClassNotFoundException 
    {
        Class class1 = Class.forName("com.java.Sample");
        Class class2 = class1.getSuperclass();
        System.out.println("super classes are : ");
        while(class2!=null)
        {
            System.out.println(class2.getName());
            class1 = class2;
            class2 = class1.getSuperclass();
        }
    }
}
/*

super classes are : 
A
B
java.lang.Object

*/