单项选择题
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.
单项选择题 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? ()
单项选择题 11. class Payload { 12. private int weight; 13. public Payload(int wt) { weight = wt; } 13. public void setWeight(mt w) { weight = w; } 15. public String toString { return Integer.toString(weight); } 16. } 17. 18. public class TestPayload { 19. static void changePayload(Payload p) { 20. /* insert code here */ 21. } 22. 23. public static void main(String[] args) { 24. Payload p = new Payload(); 25. p.setWeight(1024); 26. changePayload(p); 27. System.out.println(”The value of p is “+ p); 28. } 29. } Which statement, placed at line 20, causes the code to print “The value of p is 420.”?()
多项选择题 11.publicclassCommander{ 12.publicstaticvoidmain(String[]args){ 13.StringmyProp=/*insertcodehere*/ 14.System.out.println(myProp); 15.} 16.} andthecommandline: java-Dprop.custom=gobstopperCommander Whichtwo,placedonline13,willproducetheoutputgobstopper?()