Object Class

When you declare a class, why does it automatically extends to object class? Give 2 reasons.

Questions by zoomer09

Showing Answers 1 - 6 of 6 Answers

Object class is the super class of all the classes provided by java.lang
package.  And I think you know that all the basic functions to write a
program like println() are the content of the classes provided by java.lang. I
think this may be the reason that it will automatically extend the object class
(need not to extend the object class).   Because you must have to
write the basic functions to write any program in java. It is only for reducing
time to write any program nothing else.


  Was this answer useful?  Yes

When preparing the Java by JavaPeople they thought like every object what we prepare should have some common property so that we can do some basic operations like for example clone() method.  So what is the purpose of clone() method means in future at any case object has to be cloned in such requirements we use clone() method to clone any object in the world.  Another example what ever the operation we are performing in the computer is based on threads only right.  In the same way java also provides support for threads to handle some operations so every thread in java is associated with object only so we provide some common methods for all objects like wait(), notify(), notifyAll().  Here we can provide there methods in Thread class also but we are not providing in Thread class since every thread is associated with object only so every object is already extending the Object class so we provide those methods in Object class.

Here we need to remember only one thing i.e do not think too depth if
you go like that you get confused. Remember the common issue like every Object in the world should have some property so that property is provided by using Object class.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions