多选题 What two must the programmer do to correct the compilation errors?()
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
单选题 1) class Person { 2) public void printValue(int i, int j) {/*…*/ } 3) public void printValue(int i){/*...*/ } 4) } 5) public class Teacher extends Person { 6) public void printValue() {/*...*/ } 7) public void printValue(int i) {/*...*/} 8) public static void main(String args[]){ 9) Person t = new Teacher(); 10) t.printValue(10); 11) } 12) } Which method will the statement on line 10 call? ()
on line 2
on line 3
on line 6
on line 7
单选题 20. public float getSalary(Employee e) { 21. assert validEmployee(e); 22. float sal = lookupSalary(e); 23. assert (sal>0); 24. return sal; 25. } 26. private int getAge(Employee e) { 27. assert validEmployee(e); 28. int age = lookupAge(e); 29. assert (age>0); 30. return age; 31. } Which line is a violation of appropriate use of the assertion mechanism?()
line 21
line 23
line 27
line 29
单选题 public static void parse(String str) { try { float f= Float.parseFloat(str); } catch (NumberFormatException nfe) { f= 0; } finally { System.out.println(f); } } public static void main(String[] args) { parse(”invalid”); } What is the result?()
0.0
Compilation fails.
A ParseException is thrown by the parse method at runtime.
A NumberFormatException is thrown by the parse method at runtime.
单选题 Which statement is true about the set variable on line 12?()
The set variable contains all six elements from the coll collection, and the order is guaranteed to be preserved.
The set variable contains only three elements from the coll collection, and the order is guaranteed to be preserved.
The set variable contains all six elements from the coll collection, but the order is NOT guaranteed to be preserved.
The set variable contains only three elements from the coll collection, but the order is NOT guaranteed to be preserved.
多选题 Which of the following statements are legal?()
long l = 4990;
int i = 4L;
float f = 1.1;
double d = 34.4;
double t = 0.9F;
多选题 Which statements about static inner classes are true?()
A static inner class requires a static initializer.
A static inner class requires an instance of the enclosing class.
A static inner class has no reference to an instance of the enclosing class.
A static inner class has access to the non-static members of the outer class.
Static members of a static inner class can be referenced using the class name of the static inner class.
单选题 static void test() throws Error { if (true) throw new AssertionError(); System.out.print(”test “); } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } System.out.print(”elld “); } What is the result?()
end
Compilation fails.
exception end
exception test end
A Throwable is thrown by main.
An Exception is thrown by main.
单选题 What is the result?()
Hello
Hello World
Compilation fails.
Hello World 5
The code runs with no output.
An exception is thrown at runtime.
单选题 Given a class Repetition: 1. package utils; 2. 3. public class Repetition { 4. public static String twice(String s) { return s + s; } 5. } and given another class Demo: 1. // insert code here 2. 3. public class Demo { 4. public static void main(String[] args) { 5. System.out.println(twice(”pizza”)); 6. } 7. } Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()
import utils.*;
static import utils.*;
import utils.Repetition.*;
static import utils.Repetition. *;
import utils.Repetition.twice();
import static utils.Repetition.twice;
static import utils.Repetition.twice;