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

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


参考解析

解析: 暂无解析

相关考题:

class A{public int getNumber(int a){return a+1;}}class B extends A{public int getNumber(int a, char c){return a+2;}public static void main(String[] args){B b=new B();System.out.println(b.getNumber(0));}}what is the result?()A.compilation succeeds and 1 is printedB.compilation succeeds and 2 is printedC.compilation succeeds and 3 is printedD.An error at this program cause compilation to fail

在如下源代码文件Test.java中, 哪个是正确的类定义?() A.public class test { public int x = 0; public test(int x) { this.x = x; } }B.public class Test{ public int x=0; public Test(int x) { this.x = x; } }C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }D.public class

在下列源代码文件Test.java中,正确定义类的代码是( )。A.pblic class test { public int x=0; public test(int x) { this. x=x;} }B.public class Test { public int x=0; public Test(int x) { this. x=x;} }C.public class Test extends T1,T2{ public int x = 0; public Test(int x){ this. x = x; } }D.protected class Test extends T2{ public int x = 0; public Test(int x) { this. x = x; } }

在下列源代码文件Test.java中, ( )是正确的类定义。A.public class test{B.public class Test{ public int x=0;public int x=0; public test (intx) public Test (int x){ {this.x=x; this.x=x;} }} }C.public class Test extends T1,T2{D.protected class Test extends T2{ public int=0;public int x=0; public Test(int x){Public Test (int x){ this.x=x;this.x=x: }} }}

在下列源代码文件Test.java中,哪个选项是正确的类定义? ( )A.public class test { public int x=0; public test(int x) { this.x=x; } }B.public class Test { public int x=0; public Test(int x) { this.x=x; } }C.public class Test extends Ti,T2 { public int x=0; public Test(int x) { this.x=x; } }D.protected class Test extends T2 { public int x=0; public Test(int x) { this.x=x; } }

1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?() A、 Line 4 of class Target can be changed to return i++;B、 Line 2 of class Target can be changed to private int i = 1;C、 Line 3 of class Target can be changed to private int addOne() {D、 Line 2 of class Target can be changed to private Integer i = 0;

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.

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:}

现有:   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"); }

Given:  1.  public interface Foo {  2.  int k = 4:  3.  }   Which three are equivalent to line 2?()A、 final int k = 4:B、 public int k = 4:C、 static int k = 4:D、 private int k = 4:E、 abstract int k = 4:F、 volatile int k = 4:G、 transient int k = 4:H、 protected int k = 4:

Given:  1.  public class ConstOver {  2.  public constOver(int x, int y, int z) {  3.  }  4.  }   Which two overload the ConstOver Constructor?()A、 ConstOver() {}B、 protected int ConstOver(){}C、 private ConstOver(int z, int y, byte x ) {}D、 public Object ConstOver(Int x, int y, int z) {}E、 pubic void ConstOver (byte x, byte y, byte z) {}

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...}

1. public class Test {  2. int x= 12;  3. public void method(int x) {  4. x+=x;  5. System.out.println(x);  6. }  7. }  Given:  34. Test t = new Test();  35. t.method(5);  What is the output from line 5 of the Test class?() A、 5B、 10C、 12D、 17E、 24

public class Parent {     int change() {…}     }  class Child extends Parent {     }  Which methods can be added into class Child?()    A、 public int change(){}B、 int chang(int i){}C、 private int change(){}D、 abstract int chang(){}

1. public class A {  2. public String doit(int x, int y) {  3. return “a”;  4. }  5.  6. public String doit(int... vals) {  7. return “b”;  8. } 9. }  Given:  25. A a=new A();  26. System.out.println(a.doit(4, 5));  What is the result?() A、 Line 26 prints “a” to System.out.B、 Line 26 prints „b” to System.out.C、 An exception is thrown at line 26 at runtime.D、 Compilation of class A will fail due to an error in line 6.

public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()A、 public class Circle implements Shape { private int radius; }B、 public abstract class Circle extends Shape { private int radius; }C、 public class Circle extends Shape { private int radius; public void draw(); }D、 public abstract class Circle implements Shape { private int radius; public void draw(); }E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

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; }

单选题1. public class A {  2. public String doit(int x, int y) {  3. return “a”;  4. }  5.  6. public String doit(int... vals) {  7. return “b”;  8. } 9. }  Given:  25. A a=new A();  26. System.out.println(a.doit(4, 5));  What is the result?()A Line 26 prints “a” to System.out.B Line 26 prints „b” to System.out.C An exception is thrown at line 26 at runtime.D Compilation of class A will fail due to an error in line 6.

单选题1. public class Test {  2. int x= 12;  3. public void method(int x) {  4. x+=x;  5. System.out.println(x);  6. }  7. }  Given:  34. Test t = new Test();  35. t.method(5);  What is the output from line 5 of the Test class?()A 5B 10C 12D 17E 24

多选题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()?Aprivate void set Var(int a, float c, int b) {}Bprotected void set Var(int a, int b, float c) {}Cpublic int set Var(int a, float c, int b) {return a:}Dpublic int set Var(int a, int b, float c) {return a:}Eprotected float set Var(int a, int b, float c) {return c:}

多选题public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()Apublic class Circle implements Shape { private int radius; }Bpublic abstract class Circle extends Shape { private int radius; }Cpublic class Circle extends Shape { private int radius; public void draw(); }Dpublic abstract class Circle implements Shape { private int radius; public void draw(); }Epublic class Circle extends Shape { private int radius;public void draw() {/* code here */} }Fpublic abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

单选题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: 8B Compilation fails.C Value is: 12D Value is: -12E The code runs with no output.F An exception is thrown at runtime.

多选题Given:  1.  public interface Foo {  2.  int k = 4:  3.  }   Which three are equivalent to line 2?()Afinal int k = 4:Bpublic int k = 4:Cstatic int k = 4:Dprivate int k = 4:Eabstract int k = 4:Fvolatile int k = 4:Gtransient int k = 4:Hprotected int k = 4:

多选题Given:  1.  public class ConstOver {  2.  public constOver(int x, int y, int z) {  3.  }  4.  }   Which two overload the ConstOver Constructor?()AConstOver() {}Bprotected int ConstOver(){}Cprivate ConstOver(int z, int y, byte x ) {}Dpublic Object ConstOver(Int x, int y, int z) {}Epubic void ConstOver (byte x, byte y, byte z) {}

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

多选题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?()AChange line 2 to: public int a;BChange line 2 to: protected int a;CChange line 13 to: public Sub() { this(5); }DChange line 13 to: public Sub() { super(5); }EChange line 13 to: public Sub() { super(a); }

多选题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?()Apublic int blipvert(int x) { return 0; }Bprivate int blipvert(int x) { return 0; }Cprivate int blipvert(long x) { return 0; }Dprotected long blipvert(int x, int y) { return 0; }Eprotected int blipvert(long x) { return 0; }Fprotected long blipvert(long x) { return 0; }Gprotected long blipvert(int x) { return 0; }