The object class in java. || How to use object class in java programming language. || Explain object class in java. || Example of object class in java.



The Object Class


There is one special class, Object, defined by Java. All other classes are sub-classes of Object. That is, Object is a super-class of all other classes. This means that a reference variable of type Object can refer to an object of any other class. Also, since arrays are implemented as classes, a variable of type Object can also refer to any array.

Object defines the following methods, which means that they are available in every object.




The methods getClass( ), notify( ), notifyAll( ), and wait( ) are declared as final.

You may override the others.

The equals( ) method compares the contents of two objects. It returns true if the objects are equivalent, and false otherwise.

The toString( ) method returns a string that contains a description of the object on which it is called. Also, this method is automatically called when an object is output using println( ). Many classes override this method.





Post a Comment

Please do not enter any spam link in the comment box