It is non final and concrete class available in java.lang package.
As java.lang package by default imported in all java classes there is no need to extend object class explicitly.
In java all classes (not interfaces) are directly or indirectly extended from java.lang.Object class
In other words java.lang.Object is ultimate base class/root class of java class hierarchy.
Object class do not extend any class or implement any interface.
It does not contain nested type as well as field.
Object class contains 11 methods.
It contains default constructor
Object object=new Object(); ok
Object object= new Object(“Hello”); Not Ok
Consider following code:
Class Person{
}
Class Employee extends Person{
}
In above code, java.lang.object is direct super class of class Person
In case of class Employee, class Person is direct super class and class object is indirect super class.
Methods of object class
1. public String toString();
2. public boolean equals(Object obj);
3. public native int hashCode( );
4. protected native Object clone( )throws CloneNotSupportedException.
5. protected void finalize( void )throws Throwable.
6. public final native Class getClass( );
7. public final void wait( )throws InterruptedException
8. public final native void wait( long timeout)throws InterruptedException
9. public final void wait( long timeout, int nanos)throws InterruptedException
10. public final native void notify( );
11. public final native void notifyAll();
Comments
Post a Comment