SuperClass

Object o = new String();
Class sup = o.getClass().getSuperclass();  // java.lang.Object

// Superclass of Object is null
o = new Object();
sup = o.getClass().getSuperclass();        // null

// Although the type of o2 is an interface, getSuperclass() returns the object's superclass
Runnable o2 = new Runnable() {
    public void run() {
    }
};
sup = o2.getClass().getSuperclass();       // java.lang.Object

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.