Value is: 8
Compilation fails.
Value is: 12
Value is: -12
第1题:
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?()
第2题:
12. String csv = “Sue,5,true,3”; 13. Scanner scanner = new Scanner( csv); 14. scanner.useDelimiter(”,”); 15. int age = scanner.nextInt(); What is the result?()
第3题:
public class Foo { public int a; public Foo() { a = 3; } public void addFive() { a += 5; } } and: public class Bar extends Foo { public int a; public Bar() { a = 8; } public void addFive() { this.a +=5; } } invoked with: Foo foo = new Bar(); foo.addFive(); System.out.println(”Value: “+ foo.a); What is the result?()
第4题:
assert value == null;
assert value != null, value is null;
if (value == null) { throw new AssertionException(value is null); }
if (value == null) { throw new IllegalArgumentException(value is null); }
第5题:
Compilation fails.
ClassC is displayed.
The code runs with no output.
An exception is thrown at runtime.
第6题:
Foo has the value of “”
Foo has the value of null.
Foo has the value of “blue”
Foo has the value of “green”
An exception is thrown.
The code will not compile.
第7题:
Compilation of class A fails.
Line 28 prints the value 3 to System.out.
Line 28 prints the value 1 to System.out.
Compilation fails because of an error on line 28.
A runtime error occurs when line 25 executes.
第8题:
120M
320M
480M
600M
第9题:
Compilation of class A fails.
Line 28 prints the value 3 to System.out.
Line 28 prints the value 1 to System.out.
A runtime error occurs when line 25 executes.
Compilation fails because of an error on line 28.
第10题:
Compilation of class A fails.
Line 28 prints the value 3 to System.out.
Line 28 prints the value 1 to System.out.
A runtime error occurs when line 25 executes.
Compilation fails because of an error on line 28.
第11题:
assert value == null;
assert value !null, “value is null”;
if (value == null) { throw new AssertionException(”value is null”);
if (value == null) { throw new IllegalArgumentException(”value is null”);
第12题:
1
2
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第13题:
11. public void someMethod(Object value) { 12. // check for null value .... 20. System.out.println(value.getClass()); 21. } What, inserted at line 12, is the appropriate way to handle a null value?()
第14题:
public class ClassA { public int getValue() { int value=0; boolean setting = true; String title=”Hello”; (value || (setting && title == “Hello”)) { return 1; } (value == 1 & title.equals(”Hello”)) { return 2; } } } And: ClassA a = new ClassA(); a.getValue(); What is the result?()
第15题:
Examine the exhibit to view the parameters set in your parameter file. (Click the Exhibit(s) button.) You restart the instance. To what value will the MEMORY_MAX_TARGET parameter be set by default?()
第16题:
Value: 3
Value: 8
Value: 13
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第17题:
Compilation of class A fails.
Line 28 prints the value 3 to System.out.
Line 28 prints the value 1 to System.out.
A runtime error occurs when line 25 executes.
Compilation fails because of an error on line 28.
第18题:
The code runs with no output.
Compilation fails.
An exception is thrown at runtime.
ClassC is displayed.
第19题:
Line 26 prints "a" to System.out.
Line 26 prints "b" to System.out.
An exception is thrown at line 26 at runtime.
Compilation of class A will fail due to an error in line 6.
第20题:
Value is: 8
Compilation fails.
Value is: 12
Value is: -12
The code runs with no output.
An exception is thrown at runtime.
第21题:
Compilation fails.
After line 15, the value of age is 5.
After line 15, the value of age is 3.
An exception is thrown at runtime.
第22题:
Compilation fails.
exception is thrown at runtime.
The attribute id in the ItemTest object remains unchanged.
The attribute id in the ItemTest object is modified to the new value.
A new ItemTest object is created with the preferred value in the id attribute.
第23题:
foo has the value””
foo has the value null.
An exception is thrown.
The code will not compile.