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
正确答案:B
答案解析:有
微信扫一扫手机做题