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.printIn(b.getNumber())  }   }   What is the result?()

题目

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.printIn(b.getNumber())  }   }   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.

相似考题
参考答案和解析
正确答案:C
更多“class A {  ”相关问题
  • 第1题:

    下面程序输出的结果为 #include"iostream.h” class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASS B"<<endl;} ~B(){} }; void main() { A*p; p=new B;

    A.CLASS A CLASS B CLASS B CLASS B

    B.CLASS A CLASS B CLASS A CLASS B

    C.CLASS A CLASS B CLASS B

    D.CLASS A CLASS B


    正确答案:C

  • 第2题:

    对于下面( )类定义,可以通过“newJ_Class()”生成类J_Class的实例对象。

    A、publicclassJ_Class{

    publicJ_Class(void){}

    }

    B、publicclassJ_Class{}

    C、publicclassJ_Class{

    publicJ_Class(Strings){}

    }

    D、publicclassJ_Class{

    publicvoidJ_Class(){}

    publicJ_Class(Strings){}


    正确答案:B

  • 第3题:

    public class SomeException {  } Class a:  public class a {  public void doSomething() { }  } Class b:  public class b extends a {  public void doSomething() throws SomeException { }  }  Which is true about the two classes?() 

    • A、 Compilation of both classes will fail.
    • B、 Compilation of both classes will succeed.
    • C、 Compilation of class a will fail. Compilation of class b will succeed.
    • D、 Compilation of class a will fail. Compilation of class a will succeed.

    正确答案:D

  • 第4题:

    以下哪种不属于GPRS手机类型?()

    • A、Class D
    • B、Class A
    • C、Class B
    • D、Class C

    正确答案:A

  • 第5题:

    Which class of Cisco access points operate under IEEE 802.3af power?()

    • A、Class A
    • B、Class 1
    • C、Class 2
    • D、Class 3
    • E、Class 4

    正确答案:D

  • 第6题:

    In which two cases does the compiler supply a default constructor for class A?()  

    • A、 class A{}
    • B、 class A { public A(){} }
    • C、 class A { public A(int x){} }
    • D、 class Z {} class A extends Z { void A(){} }

    正确答案:A,D

  • 第7题:

    Which statement about static inner classes is true?()

    • A、 An anonymous class can be declared as static.
    • B、 A static inner class cannot be a static member of the outer class.
    • C、 A static inner class does not require an instance of the enclosing class.
    • D、 Instance members of a static inner class can be referenced using the class name of the static inner class.

    正确答案:C

  • 第8题:

    在MCDU电子状态页报告里能查看故障()

    • A、Class1&Class3
    • B、Class2&Class3
    • C、Class1&Class2
    • D、Class1,Class2&Class3

    正确答案:D

  • 第9题:

    关于嵌套列的用法,错误的是()

    • A、<div class=“row”><br><div class=“col-sm-1”>
    • B、<div class=“col-sm-1”><br><div class=“row”><br> 
    • C、<div class=“row”><br><div class=“container”><br><div class=“col-xs-1”><br> 
    • D、<div class=“container”><br><div class=“row”><br><div class=“col-xs-1”>

    正确答案:C

  • 第10题:

    Which of the following class networks contains 65,534 hosts?()

    • A、Class A
    • B、Class B
    • C、Class C
    • D、Class D

    正确答案:B

  • 第11题:

    What produces a compiler error?()  

    • A、 class A { public A(int x) {} }
    • B、 class A {} class B extends A { B() {} }
    • C、 class A { A() {} } class B { public B() {} }
    • D、 class Z { public Z(int) {} } class A extends Z {}

    正确答案:D

  • 第12题:

    单选题
    public class SomeException {  } Class a:  public class a {  public void doSomething() { }  } Class b:  public class b extends a {  public void doSomething() throws SomeException { }  }  Which is true about the two classes?()
    A

     Compilation of both classes will fail.

    B

     Compilation of both classes will succeed.

    C

     Compilation of class a will fail. Compilation of class b will succeed.

    D

     Compilation of class a will fail. Compilation of class a will succeed.


    正确答案: B
    解析: 暂无解析

  • 第13题:

    下面程序输出的结果为( )。 #inClUde”iostream.h” Class A {public: A(){cout<<“CLASS A”<<endl;} ~A()<)}; class B:public A {public: B(){cout<<”CLASSB”<<endl;} ~B(){}}; void main() {A*p; p=new B; B *q; q=new B;}

    A.CLASS A CLASS B

    B.CLASS A CLASS B CLASS B

    C.CLASS A ClASS B

    D.CLASS A CLASS B CLASS A CLASS B CLASS B CLASS B


    正确答案:C
    解析: 本题考查类的继承、类的实例化和构造函数、析构函数的调用方式和何时调用。每实例化一个类就要调用其构造函数,结束运行该实例后调用析构函数。

  • 第14题:

    Which statement is NOT true concerning the stowage of class 1 explosives ________.

    A.Class 1.1 explosives may be stowed with class 9 dangerous substances

    B.Class 1.4 explosives must be“separated from”a stow of class 5.1 oxidizing materials

    C.Class 1.4 explosives may not be stowed in the same hold with class 6.1 poisons

    D.Class 1.4 explosives must be“separated from”a stow of class 8 corrosive materials


    正确答案:C

  • 第15题:

    以下GPRSMS中级别最高的为()。

    • A、Class A
    • B、Class B
    • C、Class C
    • D、Class D

    正确答案:A

  • 第16题:

    GPRS手机类型可分为()。

    • A、CLASS A
    • B、CLASS B
    • C、CLASS C
    • D、CLASS D

    正确答案:A,B,C

  • 第17题:

    Which of the following class networks represents a possibility of being further subnetted into 2 subnets of 128 hosts per subnet?()

    • A、Class A
    • B、Class B
    • C、Class C
    • D、Class D

    正确答案:C

  • 第18题:

    Which declaration prevents creating a subclass of an outer class?()

    • A、 Static class FooBar{}
    • B、 Private class FooBar{}
    • C、 Abstract public class FooBar{}
    • D、 Final public class FooBar{}
    • E、 Final abstract class FooBar{}

    正确答案:D

  • 第19题:

    Which thefollowingstatements about static inner classes is true?()

    • A、 An anonymous class can be declared as static.
    • B、 A static inner class cannot be a static member of the outer class.
    • C、 A static inner class does not require an instance of the enclosing class.
    • D、 Instance member of a static inner class can be referenced using the class name of the staticinner class.

    正确答案:C

  • 第20题:

    根据栅格系统的标准用法,错误的是()

    • A、<div class="container"><br><div class="row"> 
    • B、<div class="row"><br><div class="col-md-1"> 
    • C、<div class="row"><br><div class="container"> 
    • D、<div class="col-md-1"><br><div class= "row">

    正确答案:C

  • 第21题:

    Which of the following class addresses is reserved for multicast?()

    • A、 Class A
    • B、 Class B
    • C、 Class C
    • D、 Class D

    正确答案:D

  • 第22题:

    Which statements about static inner classes are true?()

    • A、 A static inner class requires a static initializer.
    • B、 A static inner class requires an instance of the enclosing class.
    • C、 A static inner class has no reference to an instance of the enclosing class.
    • D、 A static inner class has access to the non-static members of the outer class.
    • E、 Static members of a static inner class can be referenced using the class name of the static inner  class.

    正确答案:C,E

  • 第23题:

    单选题
    Which declaration prevents creating a subclass of an outer class?()
    A

     Static class FooBar{}

    B

     Private class FooBar{}

    C

     Abstract public class FooBar{}

    D

     Final public class FooBar{}

    E

     Final abstract class FooBar{}


    正确答案: A
    解析: 暂无解析

  • 第24题:

    单选题
    What produces a compiler error?()
    A

     class A { public A(int x) {} }

    B

     class A {} class B extends A { B() {} }

    C

     class A { A() {} } class B { public B() {} }

    D

     class Z { public Z(int) {} } class A extends Z {}


    正确答案: A
    解析: 暂无解析