Question 764: class Test { private Demo d; void start() { d = new Demo(); this.takeDemo(d); /* Line 7 */ } /* Line 8 */ void takeDemo(Demo demo) { demo = null; demo = new Demo(); } }When is the Demo object eligible for garbage collection?
tcs
wipro
infosys
general
aptitude
garbage-collections
java-programming
Option D is correct. By a process of elimination.Option A is wrong. The variabledis a member of theTestclass and is never directly set to null.Option B is wrong. A copy of the variabledis set to null and not the actual variabled.Option C is wrong. The variabledexists outside thestart()method (it is a class member). So, when thestart()method finishes the variabledstill holds a reference.