Google Interview Question
SDE1sCountry: United States
Each non-primitive type (like Integer but not int), inherits from the Object class the method getClass(). this getClass() further supports .getName(), which returns the name of the class of the object.
For example:
String s="blabla";
System.out.println(s.getClass().getName()); //returns java.lang.String
Integer i=1;
System.out.println(s.getClass().getName()); //returns java.lang.Integer
- Anonymous January 24, 2014