0
1
2
Compilation fails.
第1题:
设有类定义如下:
class Base{
public Base(int i){}
}
public class MyOver extends Base{
public static void main(String arg[]){
MyOver m = new MyOver(10);
}
MyOver(int i){
super(i);
}
MyOver(String s, int i){
this(i);
//Here
}
}
以下哪条语句可以安排在//Here处 ?
A.MyOver m = new MyOver();
B.super();
C.this("Hello",10);
D.Base b = new Base(10);
第2题:
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) {} }
第3题:
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?()
第4题:
public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println( super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()
第5题:
smith,SALES
null,SALES
smith,null
null,null
编译错误
第6题:
smith
null
SALES
编译错误
第7题:
The code will fail to compile.
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.
Class c has three constructors.
Objects of class b cannot be constructed.
At most one of the constructors of each class is called as a result of constructing an object of class c.
第8题:
4, 4
4, 5
5, 4
5, 5
The code will not compile.
第9题:
京巴
京巴 Dog
null
Dog京巴
第10题:
Change line 2 to: public int a;
Change line 2 to: protected int a;
Change line 13 to: public Sub() { this(5); }
Change line 13 to: public Sub() { super(5); }
Change line 13 to: public Sub() { super(a); }
第11题:
smith
null
SALES
编译错误
第12题:
Just after line 13.
Just after line 14.
Just after line 15.
Just after line 16 (that is, as the method returns).
第13题:
public class Pet{ private String name; public Pet(String name){ this.name = name; } public void speak(){ System.out.print(name); } } public class Dog extends Pet{ public Dog(String name){ super(name); } public void speak(){ super.speak(); System.out.print(“ Dog ”); } } 执行代码 Pet pet = new Dog(“京巴”); pet.speak(); 后输出的内容是哪项?()
第14题:
Public class test ( Public static void stringReplace (String text) ( Text = text.replace (‘j’ , ‘i’); ) public static void bufferReplace (StringBuffer text) ( text = text.append (“C”) ) public static void main (String args[]} ( String textString = new String (“java”); StringBuffer text BufferString = new StringBuffer (“java”); stringReplace (textString); BufferReplace (textBuffer); System.out.printLn (textString + textBuffer); ) ) What is the output?()
第15题:
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?()
第16题:
class super { public int getLength() {return 4;} } public class Sub extends Super { public long getLength() {return 5;} public static void main (Stringargs) { super sooper = new Super (); Sub sub = new Sub(); System.out.printIn( sooper.getLength()+ “,” + sub.getLength() }; } What is the output?()
第17题:
0
1
2
Compilation fails.
第18题:
4,4
4,5
5,4
5,5
Compilation fails.
第19题:
420 is the output.
An exception is thrown at runtime.
All constructors must be declared public.
Constructors CANNOT use the private modifier.
Constructors CANNOT use the protected modifier.
第20题:
Compilation will fail.
Compilation will succeed and the program will print “0”
Compilation will succeed and the program will print “1”
Compilation will succeed and the program will print “2”
第21题:
第22题:
smith,SALES
null,SALES
smith,null
null,null
第23题:
insert a call to this() in the Car constructor
insert a call to this() in the MeGo constructor
insert a call to super() in the MeGo constructor
insert a call to super(vin) in the MeGo constructor
change the wheelCount variable in Car to protected
change line 3 in the MeGo class to super.wheelCount = 3;
第24题:
4, 4
4, 5
5, 4
5, 5
The code will not compile.