class Bar { } class Test { Bar doBar() { Bar b = new Bar(); /* Line 6 */ return b; /* Line 7 */ } public static void main (String args[]) { Test t = new Test(); /* Line 11 */ Bar newBar = t.doBar(); /* Line 12 */ System.out.println('newBar'); newBar = new Bar(); /* Line 14 */ System.out.println('finishing'); /* Line 15 */ } } At what point is the Bar object, created on line 6, eligible for garbage collection? - Study24x7
Social learning Network
09 Mar 2023 06:36 PM study24x7 study24x7

class Bar { } class Test { Bar doBar() { Bar b = new Bar(); /* Line 6 */ return b; /* Line 7 */ } public static void main (String args[]) { Test t = new Test(); /* Line 11 */ Bar newBar = t.doBar(); /* Line 12 */ ...

See more

A

after line 12

B

after line 14

C

after line 7, when doBar() completes

D

after line 15, when main() completes

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles