black

SCJP程序员认证考试

登录

单项选择题

1. class A { 
2. public byte getNumber ()  { 
3.   return 1; 
4.   } 
5. } 
6.   
7. class B extends A { 
8. public short getNumber()  { 
9.  return 2; 
10. } 
11.   
12. public static void main (String args[]) {  
13.    B  b = new B (); 
14.      System.out.printIn(b.getNumber())    
15.   } 
16. }   
What is the result?()  

A. Compilation succeeds and 1 is printed.
B. Compilation succeeds and 2 is printed.
C. An error at line 8 causes compilation to fail.
D. An error at line 14 causes compilation to fail.
E. Compilation succeeds but an exception is thrown at line 14.

相关考题

单项选择题 Whichstatementaboutstaticinnerclassesistrue?()

多项选择题 class BaseClass{  private float x= 1.0f;  protected void setVar (float f) {x = f;}  } class SubClass extends BaseClass   {  private float x = 2.0f;  //insert code here 16. }   Which two are valid examples of method overriding?()

单项选择题 1. class A {  2. public int getNumber(int a) {  3.     return a + 1;  4. }  5. }  6.    7. class B extends A {  8. public int getNumber (int a) {  9. return a + 2  10. }  11.    12. public static void main (String args[])  {  13. A a = new B();  14. System.out.printIn(a.getNumber(0));  15.    } 16. }     What is the result?()

All Rights Reserved 版权所有©求知题库网库(csqiuzhi.com)

备案号:湘ICP备14005140号-1

经营许可证号:湘B2-20140064