|
|
Authorized user can see question and answers. Please log in or sign up. 
|
#4. Given: 1. class Test { 2. private Demo d; 3. void start() { 4. d = new Demo(); 5. this.takeDemo(d); 6. } 7. 8. void takeDemo(Demo demo) { 9. demo = null; 10. demo = new Demo(); 11. } 12. }
When is the Demo object, created on line 3, eligible for garbage collection?
Show comments for this question (0)
Add comments
Link to this question
|
|
#5. Given: 1. interface Animal { 2. void soundOff(); 3. } 4. 5. class Elephant implements Animal { 6. public void soundOff() { 7. System. out. println(“Trumpet” ); 8. } 9. } 10. 11. class Lion implements Animal { 12. public void soundOff() { 13. System. out. println(“Roar” ); 14. } 15. } 16. 17. class Alpha1 { 18. static Animal get ( String choice ) { 19. if ( choice.equalsIgnoreCase( “meat eater” )) { 20. return new Lion(); 21. } else { 22. return new Elephant(); 23. } 24. } 25. }
Which compiles?
Show comments for this question (0)
Add comments
Link to this question
|
|
|
|
gen. 0.203
|
Server date 05:39 02-12-2008
|
Developed by Zip © 2006
|
|
 |
|
|