How many objects will be eligible for garbage collection after completion of compute method?
I have searched this question and everywhere the answer is 1.
public void compute(Object p)
{
Object a = new Object();
int x = 100;
String str = "abc";
}
But as far as I know, the string constant pool is a part of the heap now in Java 7 and eligible for garbage collection.
According to me, 2 objects are eligible for garbage collection i.e a
and str
.