black

SCJP程序员认证考试

登录

单项选择题

1. public class A { 
2. 
3. private int counter = 0; 
4. 
5. public static int getInstanceCount() { 
6. return counter; 
7. } 
8. 
9. public A() { 
10. counter++; 
11. } 
12. 
13. } 
Given this code from Class B: 
25.A a1 =new A(); 
26. A a2 =new A(); 
27. A a3 =new A(); 
28. System.out.printIn(A.getInstanceCount() );
What is the result?() 

A. Compilation of class A fails.
B. Line 28 prints the value 3 to System.out.
C. Line 28 prints the value 1 to System.out.
D. A runtime error occurs when line 25 executes.
E. Compilation fails because of an error on line 28.

相关考题

单项选择题 A programmer is designing a class to encapsulate the information about an inventory item. A JavaBeans component is needed to do this. The Inventoryltem class has private instance variables to store the item information:  10. private int itemId;  11. private String name;  12. private String description;  Which method signature follows the JavaBeans naming standards for modifying the itemld instance variable?()

单项选择题 A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these ways:  logIt(”log message 1 “);  logIt(”log message2”,”log message3”);  logIt(”log message4”, “log message5”, “log message6);  Which declaration satisfies this requirement?()

多项选择题 10. class Foo {  11. static void alpha() { /* more code here */ }  12. void beta() { /* more code here */ }  13. }  Which two are true?()

All Rights Reserved 版权所有©易学考试网(yxkao.com)

备案号:湘ICP备2022003000号-3