Object---The Ultimate Superhero??
Java, has become now undoubtedly the fuel of the development of the Software System Technology.Developers, now thus take the challenge to prove the feelings of Java as the best positive catalyst of their development life's reactions.They feel the Class, as the ultimate classic sense of the Java.Class,makes the expansibility of the Java's Application totally outstanding.But, in the behind of the defining,using of the classes there is some interesting concepts are embedded .Actually, all the classes that we define are subclasses by default--if you like it or not ! Because, it is the truth that all the classes have a standard class,"Object", as a root or base.So, "Object" is saying as the SUPERCLASS of every of our classes. But, the most interesting matter is to specify that the class "Object" ,need not necessary to specify in the definition of our own classes ----It here generates automatically.
There are some interesting consequences of having "Object" as a universal superclass.One of that, a variable of type Object can store a reference to an object of any class type.This is useful when we want to write method that needs to handle objects of unknown type.We can also define a parameter to the method of type, Object , in which case a reference to any type of object can be passed to the method.It gives us the flexibility to include code in the method whenever we want.
Ofcourse, our classes will inherit the members from the class Object. These all happen to be methods of which Seven are public and two are protected.
The seven public methods are:
The methods return the String object that describes the current object.
This compares the reference to the object passed as an argument with the reference to the current object and returns true if they are equals.
This method returns an object of type Class that identifies the class of current object.
This method calculates a hashcode value of an object and returns it as type int.
This is used to wake up a thread associated with the current object.
This is used to wake up all threads associated with the current object.
This method causes a thread to wait for a change in the current object.
Note that getClass(),notifyAll(),notify() and wait() cannot be overwridden in our classs definitions---they are fixed with the keyword "final"in their definition .
The two protected methods are-------
This will create an object that is a cppy of the current object regardless of type.
This is the method that is called to cleanup when an object is destroyed.
Thus, it is the actual sence of the Object class in Java.
|All times are GMT +5.5. The time now is 12:38.|