10. public class SuperCaic {  11. protected static int multiply(int a, int b) { return a * b; }  12. }  and:  20. public class SubCalc extends SuperCalc {  21. public static int multiply(int a, int b) {  22. int c = super.multiply(a, b);  23. return c; 

题目

10. public class SuperCaic {  11. protected static int multiply(int a, int b) { return a * b; }  12. }  and:  20. public class SubCalc extends SuperCalc {  21. public static int multiply(int a, int b) {  22. int c = super.multiply(a, b);  23. return c;  24. }  25. }  and:  30. SubCalc sc = new SubCalc();  31. System.out.println(sc.multiply(3,4));  32. System.out.println(SubCalc.multiply(2,2));  What is the result?()

  • A、 12 4
  • B、 The code runs with no output.
  • C、 An exception is thrown at runtime.
  • D、 Compilation fails because of an error in line 21.
  • E、 Compilation fails because of an error in line 22.
  • F、 Compilation fails because of an error in line 31.

相似考题
更多“10. public class SuperCaic {  11. protected static int multiply(int a, int b) { return a * b; }  12. }  and:  20. public class SubCalc extends SuperCalc {  21. public static int multiply(int a, int b) {  22. int c = super.multiply(a, b);  23. return c;  2”相关问题
  • 第1题:

    下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new Te

    A.0

    B.1

    C.2

    D.3


    正确答案:C

  • 第2题:

    能将程序补充完整的选项是 class Person { private int a; public int change(int m){return m; } } public class Teacher extends Person { public int b; public static void main(String arg[]) { Person p=new Person(); Teacher t=new Teacher(); int i; ______ } }

    A.i=m

    B.i=b

    C.i=p.a

    D.i=p.change(50)


    正确答案:D
    解析:本题考查类的声明。选项A中m没有被声明过,不能使用;选项B中虽然b是类Teacher的public成员变量,但在静态方法中,不能使用类中的非静态成员;选项C中a是类Person的private成员,在类外不能直接引用;选项D中change(int m)方法是public方法,并且返回一个int型值,可以通过类的实例变量p引用并赋值给一个int型变量。

  • 第3题:

    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.

    正确答案:B

  • 第4题:

    Which are syntactically valid statement at// point x?()     class Person {     private int a;  public int change(int m){  return m;  }     }  public class Teacher extends Person {     public int b;  public static void main(String arg[]){     Person p = new Person();     Teacher t = new Teacher();    int i;  // point x     }    } 

    • A、 i = m;
    • B、 i = b;
    • C、 i = p.a;
    • D、 i = p.change(30);
    • E、 i = t.b.

    正确答案:D,E

  • 第5题:

    Given:  1. public class Method Over {  2. public void set Var (int a, int b, float c) {  3. }  4. }   Which two overload the set Var method()?

    • A、 private void set Var(int a, float c, int b) {}
    • B、 protected void set Var(int a, int b, float c) {}
    • C、 public int set Var(int a, float c, int b) {return a:}
    • D、 public int set Var(int a, int b, float c) {return a:}
    • E、 protected float set Var(int a, int b, float c) {return c:}

    正确答案:A,C

  • 第6题:

    10. interface Foo { int bar(); }  11. public class Sprite {  12. public int fubar( Foo foo) { return foo.bar(); }  13. public void testFoo() {  14. fubar(  15. // insert code here  16.);  17. }  18. }  Which code, inserted at line 15, allows the class Sprite to compile?() 

    • A、 Foo { public int bar() { return 1; } }
    • B、 new Foo { public int bar() { return 1; } }
    • C、 newFoo() { public int bar(){return 1; } }
    • D、 new class Foo { public int bar() { return 1; } }

    正确答案:C

  • 第7题:

    11. abstract class Vehicle { public int speed() { return 0; } }  12. class Car extends Vehicle { public int speed() { return 60; } }  13. class RaceCar extends Car { public int speed() { return 150; }}  ......  21. RaceCar racer = new RaceCar();  22. Car car = new RaceCar();  23. Vehicle vehicle = new RaceCar();  24. System.out.println(racer.speed() + “, „ + car.speed()  25. + “, “+ vehicle.speed());  What is the result?() 

    • A、 0, 0,0
    • B、 150, 60, 0
    • C、 Compilation fails.
    • D、 150, 150, 150
    • E、 An exception is thrown at runtime.

    正确答案:D

  • 第8题:

    public class MethodOver  {  public void setVar (int a, int b, float c)  {  }  }   Which two overload the setVar method?()  

    • A、 Private void setVar (int a, float c, int b)  { }
    • B、 Protected void setVar (int a, int b, float c) { }
    • C、 Public int setVar (int a, float c, int b) (return a;)
    • D、 Public int setVar (int a, int b, float c) (return a;)
    • E、 Protected float setVar (int a, int b, float c) (return c;)

    正确答案:A,C

  • 第9题:

    class A {   public int getNumber(int a) {   return a + 1;   }   }    class B extends A {   public int getNumber (int a) {   return a + 2   }    public static void main (String args) {   A a = new B();   System.out.printIn(a.getNumber(0));   }   }   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.

    正确答案:B

  • 第10题:

    多选题
    Which are syntactically valid statement at// point x?()     class Person {     private int a;  public int change(int m){  return m;  }     }  public class Teacher extends Person {     public int b;  public static void main(String arg[]){     Person p = new Person();     Teacher t = new Teacher();    int i;  // point x     }    }
    A

    i = m;

    B

    i = b;

    C

    i = p.a;

    D

    i = p.change(30);

    E

    i = t.b.


    正确答案: C,D
    解析: A:m没有被申明过,不能使用。 
    B:虽然b是类Teacher的public成员变量,但是在静态方法中不能使用类中的非静态成员。 
    C://a是类Person的private成员,在类外不能直接引用。 
    D://change(int m)方法是public方法,并且返回一个int型值,可以通过类的实例变量p引用并赋值给一个int型变量。 
    E://b是类Teacher的public成员变量,且是int型,可以通过类的实例变量t引用并赋值给一个int型变量

  • 第11题:

    单选题
    程序:  class  TestApp{  public static void main(String[] args){  System.out.println(multiply(2,3,4,5));  }  public int multiply(int[] nums){       int result = 1;       for(int x :nums)           result *= x;       return result;   } }  程序运行后的输出是哪项?()
    A

     14

    B

     编译错误

    C

     120

    D

     24


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

  • 第12题:

    单选题
    class TestApp{   public static void main(String[] args){   System.out.println(multiply(2,3,4,5));  }   public int multiply(int… nums){   int result = 1;   for(int x :nums)   result *= x;  //result =result*x;   return result;  }  }   2、6、24、120   程序运行后的输出是哪项?()
    A

     14

    B

     编译错误

    C

     120

    D

     24


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

  • 第13题:

    Given:Which code, inserted at line 15, allows the class Sprite to compile?()

    A.Foo { public int bar() { return 1; }

    B.new Foo { public int bar() { return 1; }

    C.new Foo() { public int bar() { return 1; }

    D.new class Foo { public int bar() { return 1; }


    参考答案:C

  • 第14题:

    下列程序段中,正确的是______。 ①class MvClass { int var = 100; static int getVar() { return var; } } ②public class MyClass { final int date; void MyClass (int d) { date = d; } } ③public class MyMain { public static void main(String args[]) { System.out.println(Myclass1.date); } } class MyClass1 { int data = 10; } ④class IamAbstract { final int f; double d; abstrct void method(); }

    A.②④

    B.①③

    C.②

    D.以上都不对


    正确答案:D

  • 第15题:

    class A {  protected int method1(int a, int b) { return 0; }  }  Which two are valid in a class that extends class A?() 

    • A、 public int method1(int a, int b) { return 0; }
    • B、 private int method1(int a, int b) { return 0; }
    • C、 private int method1(int a, long b) { return 0; }
    • D、 public short method1(int a, int b) { return 0: }
    • E、 static protected int method1(int a, int b) { return 0; }

    正确答案:A,C

  • 第16题:

    class TestApp{   public static void main(String[] args){   System.out.println(multiply(2,3,4,5));  }   public int multiply(int… nums){   int result = 1;   for(int x :nums)   result *= x;  //result =result*x;   return result;  }  }   2、6、24、120   程序运行后的输出是哪项?()  

    • A、 14
    • B、 编译错误
    • C、 120
    • D、 24

    正确答案:C

  • 第17题:

    1. class Super {  2. private int a;  3. protected Super(int a) { this.a = a; }  4. }  .....  11. class Sub extends Super {  12. public Sub(int a) { super(a); }  13. public Sub() { this.a= 5; }  14. }  Which two, independently, will allow Sub to compile?()

    • A、 Change line 2 to: public int a;
    • B、 Change line 2 to: protected int a;
    • C、 Change line 13 to: public Sub() { this(5); }
    • D、 Change line 13 to: public Sub() { super(5); }
    • E、 Change line 13 to: public Sub() { super(a); }

    正确答案:C,D

  • 第18题:

    现有:   1. class Synapse {    2.    protected int gap() { return 7; }    3. }   4.     5. class Creb extends Synapse {    6.   // insert code here   7. }    分别插入到第 6 行,哪三行可以编译?()

    • A、 int gap() { return 7; }
    • B、 public int gap() { return 7; }
    • C、 private int gap(int x) { return 7; }
    • D、 protected Creb gap() { return this; }
    • E、 public int gap() { return Integer.getInteger ("42"); }

    正确答案:B,C,E

  • 第19题:

    public class Parent {  public int addValue( int a, int b) {     int s;     s = a+b;     return s;     }     }  class Child extends Parent {  }  Which methods can be added into class Child?()   

    • A、 int addValue( int a, int b ){// do something...}
    • B、 public void addValue (){// do something...}
    • C、 public int addValue( int a ){// do something...}
    • D、 public int addValue( int a, int b )throws MyException {//do something...}

    正确答案:B,C

  • 第20题:

    class TestApp{   public static void main(String[] args){   System.out.println(multiply(2,3,4,5));  }   public int multiply(int... nums){   int result=1;   for(int x:nums)   result*=x;   return result;  }  }   程序运行后的输出是哪项?()  

    • A、120
    • B、24
    • C、14
    • D、编译错误

    正确答案:D

  • 第21题:

    1. public class Blip {  2. protected int blipvert(int x) { return 0; }  3. }  4. class Vert extends Blip {  5. // insert code here  6. }  Which five methods, inserted independently at line 5, will compile?()  

    • A、 public int blipvert(int x) { return 0; }
    • B、 private int blipvert(int x) { return 0; }
    • C、 private int blipvert(long x) { return 0; }
    • D、 protected long blipvert(int x, int y) { return 0; }
    • E、 protected int blipvert(long x) { return 0; }
    • F、 protected long blipvert(long x) { return 0; }
    • G、protected long blipvert(int x) { return 0; }

    正确答案:A,C,D,E,F

  • 第22题:

    多选题
    1. class Super {  2. private int a;  3. protected Super(int a) { this.a = a; }  4. }  .....  11. class Sub extends Super {  12. public Sub(int a) { super(a); }  13. public Sub() { this.a= 5; }  14. }  Which two, independently, will allow Sub to compile?()
    A

    Change line 2 to: public int a;

    B

    Change line 2 to: protected int a;

    C

    Change line 13 to: public Sub() { this(5); }

    D

    Change line 13 to: public Sub() { super(5); }

    E

    Change line 13 to: public Sub() { super(a); }


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

  • 第23题:

    单选题
    10. public class SuperCaic {  11. protected static int multiply(int a, int b) { return a * b; }  12. }  and:  20. public class SubCalc extends SuperCalc {  21. public static int multiply(int a, int b) {  22. int c = super.multiply(a, b);  23. return c;  24. }  25. }  and:  30. SubCalc sc = new SubCalc();  31. System.out.println(sc.multiply(3,4));  32. System.out.println(SubCalc.multiply(2,2));  What is the result?()
    A

     12 4

    B

     The code runs with no output.

    C

     An exception is thrown at runtime.

    D

     Compilation fails because of an error in line 21.

    E

     Compilation fails because of an error in line 22.

    F

     Compilation fails because of an error in line 31.


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