Object Class:
Object:
an object is an instance of the class
Object Class:
It is Superclass for all the classes in java
Object class methods: equals(),hashcode(),toString(),finalize(),wait(),notify(),notifyall();
New operator is used to create a object
Constructor:
Constructor is used to initialize the instance variable/global variable
Garbage Collection:
A Garbage Collection is a process to remove the objects from heap memory which doesn’t have any references
Stack Memory: Stores reference variables
Heap Memory: Stores objects
GC will call finalize() before removing the objects.
Starting the GC Process: JVM runs the Garbage collection process
System.gc();
Runtime.gc();
It doesn’t guarantee that garbage process will start
we will just tell to JVM to start the process
Hashcode:
Hashcode is integer creates by JVM for each object
== is an operator used to check the memory address of the object
equals() used to check the content of the objects
Serializable is a marker interface
Marker interface which doesn’t have any methods
what are the other markable interfaces
Seriazable, Cloneable
Static Block:
It's executed when the class is loaded
Java static blocks will be called when JVM loads the class into memory, means it will be called only once. But constructor will be called every time when you create an object.
No comments:
Post a Comment