单项选择题

public class Item { 
private String desc; 
public String getDescription() { return desc; } 
public void setDescription(String d) { desc = d; }
public static void modifyDesc(Item item, String desc) { 
item = new Item(); 
item.setDescription(desc); 
} 
public static void main(String[] args) { 
Item it = new Item(); 
it.setDescription(”Gobstopper”); 
Item it2 = new Item(); 
it2.setDescription(”Fizzylifting”); 
modifyDesc(it, “Scrumdiddlyumptious”); 
System.out.println(it.getDescription()); 
System.out.println(it2.getDescription()); 
} 
} 
What is the outcome of the code? ()

A. Compilation fails.
B. Gobstopper      Fizzylifting
C. Gobstopper     Scrumdiddlyumptious
D. Scrumdiddlyumptious     Fizzylifltng
E. Scrumdiddlyumptious     Scrumdiddlyumptious


您可能感兴趣的试卷

你可能感兴趣的试题

2.多项选择题

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”);

4.单项选择题

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

8.单项选择题

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.