Universal Superclass
--------------------
All the classes which we define are subclasses by default. All the classes have a standard classes called Object as a base class . So Object is a superclass of every class . We don't need to specify the class Object as a base in the definition of our class . It is automatically inherited that is our class will inherit members from the class Object . Object class have seven public methods and two protected methods
Public methods are :
--------------------
1. toString() - returns the String object of the current object.
2. equals() - compares the object passed as an argument with current object, returns true if they are equal.
3. getClass() - returns a object of type Class.
4. hasCode()- calculates the hash code value for an object & returns as a type int.
5. notify() - to wake up a thread associated with the current object.
6. notifyAll() - to wake up all threads associated with the current object
7. wait() - causes a thread to wait for a change in the current object.
Two Protected methods are :
---------------------------
1. clone() - creates an object that is a copy of the current object.
2. finalize() - is called to clean up as an object is destroyed.
0 comments:
Post a Comment