Garbage collection mechanism in Java

Explain Garbage collection mechanism in Java.

1. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory.

2. The purpose of garbage collection is to identify and remove objects that are no longer needed by a program.

3. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used.

4. Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists.

5. Calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects

6. No guarantee that Garbage collection will start immediately upon request of System.gc().
Can Abstract Class have constructors?
Abstract class can have a constructor. But as we can't instantiate abstract class, we can't access it through the object...
How Java addresses the issue of portability and security
Addressing Portability: Many computers of different types with several operating systems are connected to network / internet...
Different data types for integers and floating-point values - Java
The integer and floating-point types are different in terms of the consumption of the bits which represent them...
Post your comment