Object and Class classes

Java-Object and Class classes

Object The Object class is a superclass of all other classes. This means all other classes are subclass of the Object class. Object has eleven methods : A reference variable of a superclass can be assigned a reference to any subclass derived from that superclass. Thus, a reference variable of type Object can store a reference … Read more…

Java-getClass

getClass The getClass() method returns the runtime class of an object. The getSuperclass() method returns the Class representing the superclass of the entity represented by this Class. Program Program Source class Data1 { } class Data2 extends Data1 { } class Javaapp { public static void main(String args[]) { Data2 d2 = new Data2(); System.out.println(“Data2 Superclass is : “+d2.getClass().getSuperclass()); … Read more…