background image

C. public final double methoda(); 
D. static void methoda(double d1); 
E. protected void methoda(double d1); 

5. 

 

如下代码:

public void test(int x) { 
int odd = x%2; 
if (odd) { 
System.out.println("odd); 
} else { 
System.out.println("even"); 

哪个描述正确? 
A. 编译失败. 

B. "odd" 永远被输出. 

C. "even" 永

 

远被输出
D. "odd" 输出 x 的值, 

E. "even" 输出 x

 

的值

6. 如下代码: 
public class X { 
public X aMethod() { return this;} 

public class Y extends X { 

哪两个方法能加到 Y 类的定义中? 
A. public void aMethod() {} 

B. private void aMethod() {} 

C. public void aMethod(String s) {} 

D. private Y aMethod() { return null; } 

E. public X aMethod() { return new Y(); } 

7. 如下代码: 
public class X { 
public static void main(String [] args) { 
try { 
badMethod(); 
System.out.print("A"); 

catch (Exception ex) { 
System.out.print("C"); 

finally { 
System.out.print("B"); 

System.out.print("D"); 

public static void badMethod() { 
throw new Error(); 

结果是什么? 
A. ABCD 

B. 编译失败. 

C. 显示 C,退出程序. 

D. 显示 B,C,退出程序. 

E. 显示 BCD,退出程序. 

8. 

 

如下代码:

public class Foo { 
public static void main(String[] args) { 
try {