Point No. 1
Object class is the super most class available in the Java language.
Object class is the super most class available in the Java language.
If any class or any interface is available in the java.lang package we dont have to import it. Straight away we can use it. Object class is also available in the java.lang package so we dont have to import it explicitly.
The most commonly used and required general-purpose classes and interfaces in Java programming are grouped into a package known as "java.lang". All the classes and interfaces available in this package are automatically accessible to any Java program without needing to import them explicitly.
There is no chance of writing even a single runnable Java program without using a member of "java.lang" package.
The most commonly required methods for all the classes are available in the object class.
All the classes whether they are user defined or inbuilt, all are sub classes to the Object class, whether directly or indirectly. In other words all the classes are inheriting from the Object class.
class A extends Object
{
}
Totally 12 methods are available in Object class.
If you are not overriding toString() method of Object class, and if you are trying to print the object referece you will get the Objects memory location address not the content. Ex: class-name@hashCode in the form of hexadecimal A@36baf30c
Usually we dont worry about the object's memory address instead we need the content of the object.
In order to get the content of the object instead its address we need to override toString of object class in our class.
If you try to print the referece of an object then internally it is going to call the toString method and we get the return value.
In all the wrapper classes, collection classes and in String, String Buffer and String Builder classes toString method got overrided to return the object's content.
For every object a unique code will be generated by the JVM it is called hashCode.
hashcode does not represent address of object, JVM will use this hashcode while saving objects into hashing related datastructures like hashtable, hashMap, hashSet etc.
The main advantage of saving objects based on hashcode is search operation will become easy. (the most powerful and popular algorith is hashing).
The registerNatives() method in Java was deprecated in Java 9 and removed in Java 17. It was used to register native methods with the JVM. Starting from Java 17, this method is no longer available, and native methods are instead registered using method handles.
The registerNatives() method in Java was deprecated in Java 9 and removed in Java 17. It was used to register native methods with the JVM. Starting from Java 17, this method is no longer available, and native methods are instead registered using method handles.