5. What is Object class in Java? Answer: Object class: There - TopicsExpress



          

5. What is Object class in Java? Answer: Object class: There is a class with the name Object in java.lang package which is super class of all Objects. Every class in java is direct or indirect sub class of the Object class. The Object class defines the methods to compare objects, to convert an object into a string, to notify threads(processes) regarding the availability. equals(): this method compares the references of two objects and if they are equal it returns true,otherwise false.. The way it compares the objects is dependent on the objects. toString(): This method returns a string representation of an object. for example,the String representation of an Integer object is an integer number displayed as string. getClass(): This method gives an object that contains the name of a class to which an object belongs. hashCode(): This method returns hashcode number of an object notify(): This method sends a notification to a thread which is waiting for an object. notifyAll(): This method sends a notification for all waiting threads for the object. wait(): This method causes a thread to wait till a notification is received from a notify() or notifyAll() methods. clone(): This method creates a bitwise exact copy of an existing object. finalize(): This method is called by the garbage collector when an object is removed from memory.
Posted on: Sat, 28 Jun 2014 03:48:07 +0000

Trending Topics



Recently Viewed Topics




© 2015