单项选择题

public class ItemTest { 
private final mt id; 
public ItemTest(int id) { this.id = id; } 
public void updateId(int newId) { id = newId; } 
public static void main(String[] args) { 
ItemTest fa = new ItemTest(42); 
fa.updateId(69); 
System.out.println(fa.id); 
} 
} 
What is the result?() 

A. Compilation fails.
B. An exception is thrown at runtime.
C. The attribute id in the Item object remains unchanged.
D. The attribute id in the Item object is modified to the new value.
E. A new Item object is created with the preferred value in the id attribute.


您可能感兴趣的试卷

你可能感兴趣的试题

3.多项选择题

11. public class Commander { 
12. public static void main(String[] args) { 
13. String myProp = /* insert code here */ 
14. System.out.println(myProp); 
15. } 
16. } 
and the command line: 
java -Dprop.custom=gobstopper Commander 
Which two, placed on line 13, will produce the output gobstopper?()

A. System.load(”prop.custom”);
B. System.getenv(”prop.custom”);
C. System.property(”prop.custom”);
D. System.getProperty(”prop.custom”);
E. System.getProperties().getProperty(”prop.custom”);

5.单项选择题

public class Yippee { 
public static void main(String [] args) { 
for(int x = 1; x < args.length; x++) { 
System.out.print(args[x] +“ “); 
} 
} 
} 
and two separate command line invocations: 
java Yippee 
java Yippee 1234 
What is the result?() 

A. No output is produced. 123
B. No output is produced. 234
C. No output is produced. 1234
D. An exception is thrown at runtime. 123
E. An exception is thrown at runtime. 234
F. An exception is thrown at rijntime. 1234

9.单项选择题

1. interface DoStuff2 { 
2. float getRange(int low, int high); } 
3. 
4. interface DoMore { 
5. float getAvg(int a, int b, int c); } 
6. 
7. abstract class DoAbstract implements DoStuff2, DoMore { } 
8. 
9. class DoStuff implements DoStuff2 { 
10. public float getRange(int x, int y) { return 3.14f; } } 
11. 
12. interface DoAll extends DoMore { 
13. float getAvg(int a, int b, int c, int d); } 
What is the result?() 

A. The file will compile without error.
B. Compilation fails. Only line 7 contains an error.
C. Compilation fails. Only line 12 contains an error.
D. Compilation fails. Only line 13 contains an error.
E. Compilation fails. Only lines 7 and 12 contain errors.
F. Compilation fails. Only lines 7 and 13 contain errors.
G. Compilation fails. Lines 7, 12, and 13 contain errors.