black

SCJP程序员认证考试

登录

单项选择题

1. class Bar { } 
1. class Test { 
2. Bar doBar() { 
3. Bar b = new Bar(); 
4. return b; 
5. } 
6. public static void main (String args[]) { 
7. Test t = new Test(); 
8. Bar newBar = t.doBar(); 
9. System.out.println(“newBar”); 
10. newBar = new Bar(); 
11. System.out.println(“finishing”); 
12. } 
13. }
At what point is the Bar object, created on line 3, eligible for garbage collection?()  

A. After line 8.
B. After line 10.
C. After line 4, when doBar() completes.
D. After line 11, when main() completes.

相关考题

单项选择题 1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()

单项选择题 20. public float getSalary(Employee e) {  21. assert validEmployee(e);  22. float sal = lookupSalary(e);  23. assert (sal>0);  24. return sal;  25. }  26. private int getAge(Employee e) {  27. assert validEmployee(e);  28. int age = lookupAge(e);  29. assert (age>0);  30. return age;  31. }  Which line is a violation of appropriate use of the assertion mechanism?()

单项选择题 1. class Exc0 extends Exception { }  2. class Exc1 extends Exc0 { }  3. public class Test {  4. public static void main(String args[]) {  5. try {  6. throw new Exc1();  7. } catch (Exc0 e0) {  8. System.out.println(“Ex0 caught”);  9. } catch (Exception e) {  10. System.out.println(“exception caught”);  11. }  12. }  13. }  What is the result?()

All Rights Reserved 版权所有©财会考试题库(ckkao.com)

备案号:湘ICP备2022003000号-2