Btechadda.com

OOPS/JAVA : Unit 3 -Base class Object

by hkesavaraju on Apr.02, 2010, under Java

In java, all classes use inheritance. If the parent class is not specified, all classes in java are derived from a single root class called Object. The derived assumes Object as its parent class in this case. The following program named FirstProgram illustrates this:

class FirstProgram extends Object

{

//…..

}

The class Object provides minimum functionality that is common to all objects. These include the following methods.

(i) equals(Object ob): It determines whether the argument string obj is same as the receiver. This method is often overridden to change the equality test for different classes.

(ii) getClass(): It returns the class of the receiver or object of type class.

(iii) hashCode(): It returns hash value for the object. This method should also be overridden when equals() is changed.

(iv) toString(): It converts object into a string value. This method is also often overridden.


Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...