易搜题 > 资格证大类 > 计算机编程 > 问题详情
问题详情

class A {  public byte getNumber() {  return 1;  }  }  class B extends A {  public short getNumber() {  return 2;  }  public static void main(String args[]) {  B b = new B();  System.out.println(b.getNumber()); }  }   What is the result?()

A、 1

B、 2

C、 An exception is thrown at runtime.

D、 Compilation fails because of an error in line 8.

E、 Compilation fails because of an error in line 14.

未找到的试题在搜索页框底部可快速提交,在会员中心"提交的题"查看可解决状态。 收藏该题
查看答案

相关问题推荐

  • Given the following code:     public class Person{ static int arr[] = new int[10];  public static void main(String a[]) {     System.out.println(arr[1];)     }     }  Which statement is correct?()   

    A、 When compilation some error will occur.

    B、 It is correct when compilation but will cause error when running.

    C、 The output is zero.

    D、 The output is null.

  • class super {   public float getNum() {return 3.0f;}   }   public class Sub extends Super {   }   Which method, placed at line 6, will cause a compiler error?()

    A、 Public float getNum() {return 4.0f; }

    B、 Public void getNum (){}

    C、 Public void getNum (double d){}

    D、 Public double getNum (float d) {retrun 4.0f; }

  • public class Foo {  private int val;  public foo(int v) (val = v;)  }  public static void main (String [] args)  {  Foo a = new Foo (10);  Foo b = new Foo (10);  Foo c = a;  int d = 10;  double e = 10.0;  }  Which three logical expression evaluate to true?()

    A

     (a ==c)

    B

     (d ==e)

    C

     (b ==d)

    D

     (a ==b)

    E

     (b ==c)

    F

     (d ==10.0)

  • Which will declare a method that forces a subclass to implement it? () 

    A、 Public double methoda();

    B、 Static void methoda (double d1) {}

    C、 Public native double methoda();

    D、 Abstract public void methoda();

    E、 Protected void methoda (double d1){}

  • 11. public void someMethod(Object value) {  12. // check for null value ....  20. System.out.println(value.getClass());  21. }  What, inserted at line 12, is the appropriate way to handle a null value?() 

    A、 assert value == null;

    B、 assert value !null, “value is null”;

    C、 if (value == null) { throw new AssertionException(”value is null”);

    D、 if (value == null) { throw new IllegalArgumentException(”value is null”);

联系客服 会员中心
TOP