1. 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?





Ask Your Doubts Here

Type in
(Press Ctrl+g to toggle between English and the chosen language)

Comments

  • By: guest on 02 Jun 2017 01.26 am
    Option B is correct. All references to the Bar object created on line 6 are destroyed when a new reference to a new Bar object is assigned to the variable newBar on line 14. Therefore the Bar object, created on line 6, is eligible for garbage collection after line 14. Option A is wrong. This actually protects the object from garbage collection. Option C is wrong. Because the reference in the doBar() method is returned on line 7 and is stored in newBar on line 12. This preserver the object created on line 6. Option D is wrong. Not applicable because the object is eligible for garbage collection after line 14.
Show Similar Question And Answers
QA->Rahim travelled straight from point E to F at a distance of 5 km. From F he turned left and travelled 6 km and reached point G, there he took a left turn and travelled 5 km to reach point H. He took another left turn and travelled 2 km and reached point I. How far is he from the starting point ?....
QA->There are 50 students in a class. In a class test 22 students get 25 marks each, 18 students get 30 marks each. Each of the remaining gets 16 marks. The average mark of the whole class is :....
QA->Average height of 10 students in a class is 150 cm. A boy of height 160 cm left the class and a boy of height 148 cm is admitted. Then what is the average height of the students in the class now?....
QA->Age group of the people who were eligible under the `TRYSEM` system?....
QA->A process in which a public relations representative sends out press releases to various media outlets to promote a company change, a new product or a new service is known as....
MCQ->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?....
MCQ->What will be the output of the program? class MyThread extends Thread { MyThread() { System.out.print(" MyThread"); } public void run() { System.out.print(" bar"); } public void run(String s) { System.out.println(" baz"); } } public class TestThreads { public static void main (String [] args) { Thread t = new MyThread() { public void run() { System.out.println(" foo"); } }; t.start(); } }....
MCQ->What will be the output of the program? public class Test { public static int y; public static void foo(int x) { System.out.print("foo "); y = x; } public static int bar(int z) { System.out.print("bar "); return y = z; } public static void main(String [] args ) { int t = 0; assert t > 0 : bar(7); assert t > 1 : foo(8); / Line 18 / System.out.println("done "); } }....
MCQ->What will be the output of the program? class Happy extends Thread { final StringBuffer sb1 = new StringBuffer(); final StringBuffer sb2 = new StringBuffer(); public static void main(String args[]) { final Happy h = new Happy(); new Thread() { public void run() { synchronized(this) { h.sb1.append("A"); h.sb2.append("B"); System.out.println(h.sb1); System.out.println(h.sb2); } } }.start(); new Thread() { public void run() { synchronized(this) { h.sb1.append("D"); h.sb2.append("C"); System.out.println(h.sb2); System.out.println(h.sb1); } } }.start(); } }....
MCQ->What will be the output of the program? public class Test138 { public static void stringReplace (String text) { text = text.replace ('j' , 'c'); / Line 5 / } public static void bufferReplace (StringBuffer text) { text = text.append ("c"); / Line 9 / } public static void main (String args[]) { String textString = new String ("java"); StringBuffer textBuffer = new StringBuffer ("java"); / Line 14 / stringReplace(textString); bufferReplace(textBuffer); System.out.println (textString + textBuffer); } }....
Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use | Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions
Question ANSWER With Solution