How is Garbage collection done in Java?

Answer Posted / harish

Garbage Collection is carried out based on the reference
type an object is currently in.
There are 4 types of references in java
1)strong reference
2)soft reference
3)weak reference
4)phantom reference

the last one is the weakest of the weak.
JVM will try get all those of object that are fell in this
category and try to collect it.
But it is not neccessary the object in phantom reference
phase will always be garbage collected.

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an infinite loop?

536


Does java isempty check for null?

565


Explain the importance of thread scheduler in java?

591


What is starvation?

675


What is a data structure java?

494






Why is singleton instance static?

499


What is the size of int in 64-bit jvm?

546


What is the diffrence between inner class and nested class?

554


Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.

1576


Is it safe to install java on my computer?

530


What is comparable and comparator interface? List their differences

574


What is object in java?

523


How will you load a specific locale?

534


What is the meaning of immutable regarding string?

512


What is sorting in java?

524