单选题class Super { public int getLenght() { return 4; } } public class Sub extends Super { public long getLenght() { return 5; } public static void main(String[] args) {Super sooper = new Super(); Sub sub = new Sub(); System.out.println( sooper.getLenght() + “,” + sub.getLenght() ); } } What is the output? ()A 4,4B 4,5C 5,4D 5,5E Compilation fails.

单选题
class Super { public int getLenght() { return 4; } } public class Sub extends Super { public long getLenght() { return 5; } public static void main(String[] args) {Super sooper = new Super(); Sub sub = new Sub(); System.out.println( sooper.getLenght() + “,” + sub.getLenght() ); } } What is the output? ()
A

 4,4

B

 4,5

C

 5,4

D

 5,5

E

 Compilation fails.


参考解析

解析: 暂无解析

相关考题:

若类A和类B的定义如下:includeclass A{int i,j;public:int geti(){return i;}};class 若类A和类B的定义如下: #include<malloc.h> class A { int i,j; public: int geti() { return i; } }; class B:public A { int k; public: void make() { k=i*j; } }; 则上述定义中非法的表达式是( )。A.k=i*jB.int k;C.return i;D.void make();

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

public class Something {public int addOne(final int x) {return ++x;}}这个比较明显。

public class Person {  private String name, comment;  private int age;  public Person(String n, int a, String c) {  name = n; age = a; comment = c;  }  public boolean equals(Object o) {  if(! (o instanceof Person)) return false;  Person p = (Person)o;  return age == p.age  name.equals(p.name);  }  }  What is the appropriate definition of the hashCode method in class Person?() A、 return super.hashCode();B、 return name.hashCode() + age * 7;C、 return name.hashCode() + comment.hashCode() /2;D、 return name.hashCode() + comment.hashCode() / 2 - age * 3;

class Super {  public int getLenght( ) { return 4; }  }  public class Sub extends Super {  public long getLenght( ) { return 5; }  public static void main(String[] args) {  Super sooper = new Super( );  Sub sub = new Sub( );  System.out.println(  sooper.getLenght( ) + “,” + sub.getLenght( ) );  }  } What is the output?()A、 Just after line 13.B、 Just after line 14.C、 Just after line 15.D、 Just after line 16 (that is, as the method returns).

Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }  A、The code will fail to compile.B、The constructor in a that takes an int as an argument will never be called as a result of constructing an  object of class b or c.C、Class c has three constructors.D、Objects of class b cannot be constructed.E、At most one of the constructors of each class is called as a result of constructing an object of class c.

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

class super {  public int getLength()  {return 4;}  }  public class Sub extends Super {  public long getLength() {return 5;}  public static void main (String[]args)  {  super sooper = new Super ();  Sub sub = new Sub();  System.out.printIn(  sooper.getLength()+ “,” + sub.getLength()   };  }  What is the output?()  A、 4, 4B、 4, 5C、 5, 4D、 5, 5E、 The code will not compile.

class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()  A、 0B、 1C、 2D、 Compilation fails.

class Super { public int getLenght() { return 4; } } public class Sub extends Super { public long getLenght() { return 5; } public static void main(String[] args) {Super sooper = new Super(); Sub sub = new Sub(); System.out.println( sooper.getLenght() + “,” + sub.getLenght() ); } } What is the output? ()A、 4,4B、 4,5C、 5,4D、 5,5E、 Compilation fails.

class Sock {  String size;  String color;  public boolean equals(Object o) {  Sock s = (Sock) o;  return color.equals(s.color);   }  // insert code here  }  哪两个满足 hashCode 的约定?()A、public int hashCode() { return 343; }B、public int hashCode() { return size.hashCode (); }C、public int hashCode() { return color.hashCode (); }D、public int hashCode() { return (int) (Math.random() * 1000);

class One {   public One foo() { return this; }  }  class Two extends One {  public One foo() { return this; }  }  class Three extends Two {   // insert method here  }  Which two methods, inserted individually, correctly complete the Three class?()A、 public void foo() { }B、 public int foo() { return 3; }C、 public Two foo() { return this; }D、 public One foo() { return this; }E、 public Object foo() { return this; }

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. class super {  2. public float getNum() {return 3.0f;}  3. }  4.    5. public class Sub extends Super { 6.   7. }   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; }

单选题class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()A 0B 1C 2D Compilation fails.

单选题class Super {  public Integer getLenght() { return new Integer(4); } }  public class Sub extends Super {  public Long GetLenght() { return new Long(5); }  public static void main(String[] args) { Super sooper = new Super();  Sub sub = new Sub();  System.out.println(  sooper.getLenght().toString() + “,” +  sub.getLenght().toString() ); } }  What is the output?()A 4,4B 4,5C 5,4D 5,5E Compilation fails.

多选题Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }AThe code will fail to compile.BThe constructor in a that takes an int as an argument will never be called as a result of constructing an  object of class b or c.CClass c has three constructors.DObjects of class b cannot be constructed.EAt most one of the constructors of each class is called as a result of constructing an object of class c.

单选题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; } }

单选题1. class super {  2. public float getNum() {return 3.0f;}  3. }  4.    5. public class Sub extends Super { 6.   7. }   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; }

单选题class super {  public int getLength()  {return 4;}  }  public class Sub extends Super {  public long getLength() {return 5;}  public static void main (String[]args)  {  super sooper = new Super ();  Sub sub = new Sub();  System.out.printIn(  sooper.getLength()+ “,” + sub.getLength()   };  }  What is the output?()A 4, 4B 4, 5C 5, 4D 5, 5E The code will not compile.

单选题Which line contains a constructor in this class definition?()   public class Counter { // (1)   int current, step;   public Counter(int startValue, int stepValue) { // (2)   set(startValue);   setStepValue(stepValue);  }   public int get() { return current; } // (3)   public void set(int value) { current = value; } // (4)   public void setStepValue(int stepValue) { step = stepValue; } // (5)  }ACode marked with (1) is a constructorBCode marked with (2) is a constructorCCode marked with (3) is a constructorDCode marked with (4) is a constructorECode marked with (5) is a Constructor

单选题1. class Super {  2. public float getNum() { return 3.0f; }  3. }  4.   5. public class Sub extends Super {  6.   7. }  Which method, placed at line6, causes compilation to fail?()A public void getNum(){}B public void getNum(double d){}C public float getNum() { return 4.0f; }D public double getNum(float d) { return 4.0d; }

单选题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 Score implements Comparable {  private int wins, losses;  public Score(int w, int 1) { wins = w; losses = 1; }  public int getWins() { return wins; }  public int getLosses() { return losses; }  public String toString() {  return “”; }  // insert code here  }  Which method will complete this class?()A public int compareTo(Object o) {/*mode code here*/}B public int compareTo(Score other) {/*more code here*/}C public int compare(Score s1,Score s2){/*more code here*/}D public int compare(Object o1,Object o2){/*more code here*/}

多选题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); }

多选题public class Car {  private int wheelCount;  private String vin;  public Car(String vin) {  this.vin = vin;  this.wheelCount = 4;  }  public String drive() {  return “zoom-zoom”;  }  public String getInfo() {  return “VIN: “+ vin + “wheels: “+ wheelCount;  }  }  And:  public class MeGo extends Car {  public MeGo(String vin) {  this.wheelCount = 3;  }  }  What two must the programmer do to correct the compilation errors?()Ainsert a call to this() in the Car constructorBinsert a call to this() in the MeGo constructorCinsert a call to super() in the MeGo constructorDinsert a call to super(vin) in the MeGo constructorEchange the wheelCount variable in Car to protectedFchange line 3 in the MeGo class to super.wheelCount = 3;

单选题class Super {  public int getLenght( ) { return 4; }  }  public class Sub extends Super {  public long getLenght( ) { return 5; }  public static void main(String[] args) {  Super sooper = new Super( );  Sub sub = new Sub( );  System.out.println(  sooper.getLenght( ) + “,” + sub.getLenght( ) );  }  } What is the output?()A Just after line 13.B Just after line 14.C Just after line 15.D Just after line 16 (that is, as the method returns).