Try out the public method getClass of the universal supercla

Try out the public method getClass() of the universal super-class Object by calling these methods from a String object, an Integer object and an object of one of the type Clerk which you created as described above. Print out what is returned from the getClass method.

Solution

public class GetClassExample {
   /**
   * @param args
   */
   public static void main(String[] args) {

       String str = new String();
       Integer integer = Integer.MAX_VALUE;
       Clerk clerk = new Clerk();
       System.out.println(\"For String class:\" + str.getClass());
       System.out.println(\"For Integer class:\" + integer.getClass());
       System.out.println(\"For Clerk class:\" + clerk.getClass());

   }
}

class Clerk extends Employee {

}

OUTPUT:

For String class:class java.lang.String
For Integer class:class java.lang.Integer
For Clerk class:class Clerk

Try out the public method getClass() of the universal super-class Object by calling these methods from a String object, an Integer object and an object of one o

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site