Java tutorial
class superClass { // super class } class subClass extends superClass { // sub class } public class Main { public static void main(String args[]) { superClass val1 = new superClass(); subClass val2 = new subClass(); Class cls = val1.getClass(); System.out.println(cls.getName()); cls = cls.getSuperclass(); System.out.println(cls.getName()); cls = val2.getClass(); System.out.println(cls.getName()); } }