Java Programming - Garbage Collections - Discussion
Discussion Forum : Garbage Collections - General Questions (Q.No. 1)
1.
void start() {
A a = new A();
B b = new B();
a.s(b);
b = null; /* Line 5 */
a = null; /* Line 6 */
System.out.println("start completed"); /* Line 7 */
}
When is the B object, created in line 3, eligible for garbage collection?Discussion:
59 comments Page 6 of 6.
Prabavathi.V said:
1 decade ago
Actually, garbage collection object values are always unused and it will never be absolutely certain.
Ashish Mishra said:
1 decade ago
option A
Just bcz of when object reference bcome null then it will eligible to call runtime.gc();
Just bcz of when object reference bcome null then it will eligible to call runtime.gc();
Amit said:
1 decade ago
It will throw an error while creating the reference of the object(a.s(b)).
Arnold villasanta said:
1 decade ago
Yup, D is correct.
No one knows how instance 'a' used 'b' in its method.
No one knows how instance 'a' used 'b' in its method.
Ranjani said:
1 decade ago
It's A. Java is never pass by reference..that's a C language concept..
Konapuram malli said:
1 decade ago
Option A is correct because of that object reference is null.
Mostapha said:
9 years ago
Option D.
It's depends of what a.s (b) will do if it exists.
It's depends of what a.s (b) will do if it exists.
Yuvaraju said:
9 years ago
We can assign a null to the object, so option D is correct.
Anuja said:
10 years ago
Please explain about option D.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers