Rob
SCJP 1.4
Every class does have a single Class object associated with it.]
Rob
SCJP 1.4
Originally posted by Rob Ross:
Look at the method getClass() in Object. It returns a Class object, which represents the actual runtime class of the object. Note that this isn't covered on the SCJP2.
Originally posted by victor gu:
It returns the runtime class of an object. Not a
Class object. Right?
Rob
SCJP 1.4
Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class.
Returns:
the object of type Class that represents the runtime class of the object.
Rob
SCJP 1.4
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Originally posted by Paul Anil:
If you have an object, there MUST be a class from which it has been instantiated. So, it is safe to say that an Object is an instance of a class. (In fact, this is the definition of Object)
A class that has only static methods is still a class. It cannot be an object.
The java.lang.Class class that Rob is talking about is the class that represents the actual class of the object. For example, if you have:
BaseClass b = new SubClass();
java.lang.Class c = b.getClass(); -> this will return an object of class Class which represents SubClass ( and not BaseClass).
Math in itself is just like any other class. As Rob said, the JVM keeps a java.lang.Class "object" that represents this class in the runtime.
But again, that object is of class java.lang.Class not of class java.lang.Math.
Originally posted by victor gu:
hmmmm, this is pretty clear explanation. I confused class object with Class object. A Class
object is not an object, its a runtime class represented by this Class "object". Oh la la..
victor
Rob
SCJP 1.4
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |