单选题1. class A {  2. public byte file Number ( ) { 3. return l;  4. }  5. }  6.  7. Class B extends A {  8. public short getNumber( ) {  9.  return 2;  10. }  11.  12. public short getNumber( ) {  13. B b = new B( );  14. System.out.printIn(b.getNumber( ))

题目

单选题1. class A {  2. public byte file Number ( ) { 3. return l;  4. }  5. }  6.  7. Class B extends A {  8. public short getNumber( ) {  9.  return 2;  10. }  11.  12. public short getNumber( ) {  13. B b = new B( );  14. System.out.printIn(b.getNumber( ));  15. }  16. }   What is the result()?A  Compilation succeeds and l is printed.B  Compilation succeeds and 2 printed.C  An error at line 8 cause compilation to fail.D  An error at line 14 cause complication to fail.E  Complication succeeds but an exception is thrown at line 14.


相似考题
更多“单选题1. class A {  2. public byte file Number ( ) { 3. return l;  4. }  5. }  6.  7. Class B extends A {  8. public short getNumber( ) {  9.  return 2;  10. }  11.  12. public short getNumber( ) {  13. B b = new B( );  14. System.out.printIn(b.getNumber( ))”相关问题
  • 第1题:

    1. public class A {  2. public void doit() {  3. }  4. public String doit() {  5. return “a”;  6. }  7. public double doit(int x) {  8. return 1.0;  9. }  10.}  What is the result?() 

    • A、 An exception is thrown at runtime.
    • B、 Compilation fails because of an error in line 7.
    • C、 Compilation fails because of an error in line 4.
    • D、 Compilation succeeds and no runtime errors with class A occur.

    正确答案:C

  • 第2题:

    1. class SuperClass {  2. public a geta() {  3. return new a();  4. }  5. }  6. class SubClass extends SuperClass {  7. public b geta() {  8. return new b();  9. }  10. }  Which is true?() 

    • A、 Compilation will succeed if a extends b.
    • B、 Compilation will succeed if b extends a.
    • C、 Compilation will always fail because of an error in line 7.
    • D、 Compilation will always fail because of an error in line 8.

    正确答案:B

  • 第3题:

    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

  • 第4题:

    1. class A {  2. public String toString ()  {  3. return “4”;  4. }  5. }  6. class B extends A {  7. public String toString ()   {  8. return super.toString()  + “3”;  9. }  10. }  11. public class Test {  12.   public static void main(String[]args)  {  13.      System.out.printIn(new B());  14.      }  15. }    What is the result?()  

    • A、 Compilation succeeds and 4 is printed.
    • B、 Compilation succeeds and 43 is printed.
    • C、 An error on line 9 causes compilation to fail.
    • D、 An error on line 14 causes compilation to fail.
    • E、 Compilation succeeds but an exception is thrown at line 9.

    正确答案:B

  • 第5题:

    1. class A {  3. public String to String() {  4. return “4”;  5. }  6. }  7. class B extends A {  8. public String toString() { 9. return super.toString() + “3”;  10. }  11. }  12. public class Test {  13. public static void main (String[] args) {  14. System.out.printIn(new B()); 15. }  16. }   What is the result( )?  

    • A、 Compilation succeeds and 4 is printed.
    • B、 Compilation …………… is printed.
    • C、 An error on line 9 cause compilation to fail.
    • D、 An error on line 14 cause compilation to fail.
    • E、 Compilation succeeds but an exception is thrown at line 9.

    正确答案:B

  • 第6题:

    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

  • 第7题:

    单选题
    1. public interface A {  2. public void doSomething(String thing);  3. }  1. public class AImpl implements A {  2. public void doSomething(String msg) { }  3. }  1. public class B {  2. public A doit() {  3. // more code here  4. }  5.  6. public String execute() { 7. // more code here  8. }  9. }  1. public class C extends B {  2. public AImpl doit() {  3. // more code here  4. }  5.  6. public Object execute() {  7. // more code here  8. }  9. }  Which statement is true about the classes and interfaces in the exhibit?()
    A

     Compilation will succeed for all classes and interfaces.

    B

     Compilation of class C will fail because of an error in line 2.

    C

     Compilation of class C will fail because of an error in line 6.

    D

     Compilation of class AImpl will fail because of an error in line 2.


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

  • 第8题:

    单选题
    1. class A {  2. public String toString ()  {  3. return “4”;  4. }  5. }  6. class B extends A {  7. public String toString ()   {  8. return super.toString()  + “3”;  9. }  10. }  11. public class Test {  12.   public static void main(String[]args)  {  13.      System.out.printIn(new B());  14.      }  15. }    What is the result?()
    A

     Compilation succeeds and 4 is printed.

    B

     Compilation succeeds and 43 is printed.

    C

     An error on line 9 causes compilation to fail.

    D

     An error on line 14 causes compilation to fail.

    E

     Compilation succeeds but an exception is thrown at line 9.


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

  • 第9题:

    单选题
    1. public class SimpleCalc {  2. public int value;  3. public void calculate() { value += 7; }  4. } And:  1. public class MultiCalc extends SimpleCalc {  2. public void calculate() { value -= 3; }  3. public void calculate(int multiplier) {  4. calculate();  5. super.calculate();  6. value *=multiplier;  7. }  8. public static void main(String[] args) {  9. MultiCalc calculator = new MultiCalc();  10. calculator.calculate(2);  11. System.out.println(”Value is: “+ calculator.value);  12. }  13. }  What is the result?()
    A

     Value is: 8

    B

     Compilation fails.

    C

     Value is: 12

    D

     Value is: -12

    E

     The code runs with no output.

    F

     An exception is thrown at runtime.


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

  • 第10题:

    单选题
    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.


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

  • 第11题:

    单选题
    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.


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

  • 第12题:

    单选题
    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?()
    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 13 causes compilation to fail.

    E

     An error at line 14 causes compilation to fail.


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

  • 第13题:

    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.

    正确答案:C

  • 第14题:

    1. class Pizza {  2. java.util.ArrayList toppings;  3. public final void addTopping(String topping) {  4. toppings.add(topping); 5. }  6. }  7. public class PepperoniPizza extends Pizza {  8. public void addTopping(String topping) {  9. System.out.println(”Cannot add Toppings”);  10. }  11. public static void main(String[] args) {  12. Pizza pizza = new PepperoniPizza();  13. pizza.addTopping(”Mushrooms”);  14. }  15. }  What is the result?() 

    • A、 Compilation fails.
    • B、 Cannot add Toppings
    • C、 The code runs with no output.
    • D、 A NullPointerException is thrown in Line 4.

    正确答案:A

  • 第15题:

    1. public class Test { 2. public static String output =””; 3.  4. public static void foo(int i) { 5. try { 6. if(i==1) { 7. throw new Exception(); 8. } 9. output += “1”; 10. } 11. catch(Exception e) { 12. output += “2”; 13. return; 14. } 15. finally { 16. output += “3”;17. } 18. output += “4”; 19. } 20.  21. public static void main(String args[]) { 22. foo(0); 23. foo(1); 24.  25. }26. } What is the value of the variable output at line 23?()


    正确答案:13423

  • 第16题:

    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.

    正确答案:D

  • 第17题:

    1. class A {  2. public byte file Number ( ) { 3. return l;  4. }  5. }  6.  7. Class B extends A {  8. public short getNumber( ) {  9.  return 2;  10. }  11.  12. public short getNumber( ) {  13. B b = new B( );  14. System.out.printIn(b.getNumber( ));  15. }  16. }   What is the result()?  

    • A、 Compilation succeeds and l is printed.
    • B、 Compilation succeeds and 2 printed.
    • C、 An error at line 8 cause compilation to fail.
    • D、 An error at line 14 cause complication to fail.
    • E、 Complication succeeds but an exception is thrown at line 14.

    正确答案:C

  • 第18题:

    单选题
    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.


    正确答案: D
    解析: getNumber() in B cannot override getNumber() in A; attempting to use incompatible return type: short to byte. 

  • 第19题:

    单选题
    1. class SuperClass {  2. public a geta() {  3. return new a();  4. }  5. }  6. class SubClass extends SuperClass {  7. public b geta() {  8. return new b();  9. }  10. }  Which is true?()
    A

     Compilation will succeed if a extends b.

    B

     Compilation will succeed if b extends a.

    C

     Compilation will always fail because of an error in line 7.

    D

     Compilation will always fail because of an error in line 8.


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

  • 第20题:

    单选题
    1. class Pizza {  2. java.util.ArrayList toppings;  3. public final void addTopping(String topping) {  4. toppings.add(topping); 5. }  6. }  7. public class PepperoniPizza extends Pizza {  8. public void addTopping(String topping) {  9. System.out.println(”Cannot add Toppings”);  10. }  11. public static void main(String[] args) {  12. Pizza pizza = new PepperoniPizza();  13. pizza.addTopping(”Mushrooms”);  14. }  15. }  What is the result?()
    A

     Compilation fails.

    B

     Cannot add Toppings

    C

     The code runs with no output.

    D

     A NullPointerException is thrown in Line 4.


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

  • 第21题:

    单选题
    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.


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

  • 第22题:

    单选题
    1. class A {  2. public byte file Number ( ) { 3. return l;  4. }  5. }  6.  7. Class B extends A {  8. public short getNumber( ) {  9.  return 2;  10. }  11.  12. public short getNumber( ) {  13. B b = new B( );  14. System.out.printIn(b.getNumber( ));  15. }  16. }   What is the result()?
    A

     Compilation succeeds and l is printed.

    B

     Compilation succeeds and 2 printed.

    C

     An error at line 8 cause compilation to fail.

    D

     An error at line 14 cause complication to fail.

    E

     Complication succeeds but an exception is thrown at line 14.


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

  • 第23题:

    单选题
    1. class A {  3. public String to String() {  4. return “4”;  5. }  6. }  7. class B extends A {  8. public String toString() { 9. return super.toString() + “3”;  10. }  11. }  12. public class Test {  13. public static void main (String[] args) {  14. System.out.printIn(new B()); 15. }  16. }   What is the result( )?
    A

     Compilation succeeds and 4 is printed.

    B

     Compilation …………… is printed.

    C

     An error on line 9 cause compilation to fail.

    D

     An error on line 14 cause compilation to fail.

    E

     Compilation succeeds but an exception is thrown at line 9.


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

  • 第24题:

    单选题
    1. public class A {  2. public void doit() {  3. }  4. public String doit() {  5. return “a”;  6. }  7. public double doit(int x) {  8. return 1.0;  9. }  10.}  What is the result?()
    A

     An exception is thrown at runtime.

    B

     Compilation fails because of an error in line 7.

    C

     Compilation fails because of an error in line 4.

    D

     Compilation succeeds and no runtime errors with class A occur.


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