Java Garbage Collection

Making object garbage eligible: example : Car carObj= new Car(); Garbage collection in java: In above code, System.gc() will make request JVM to run garbage collection. The finalize() method is invoked each time before the object is garbage collected. Output: