单项选择题
11. rbo = new ReallyBigObject(); 12. // more code here 13. rbo = null; 14. /* insert code here */ Which statement should be placed at line 14 to suggest that the virtual machine expend effort toward recycling the memory used by the object rbo?()
1. class Super { 2. public float getNum() { return 3.0f; } 3. } 4. 5. public class Sub extends Super { 6. 7. } Which method, placed at line6, causes compilation to fail?()
class Super { public int i = 0; public Super(String text) { i = 1; } } public class Sub extends Super { public Sub(String text) { i = 2; } public static void main(String args[]) { Sub sub = new Sub(“Hello”); System.out.println(sub.i); } } What is the result?()
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? ()
10. public class Foo implements java.io.Serializable { 11. private int x; 12. public int getX() { return x; } 12.publicFoo(int x){this.x=x; } 13. private void writeObject( ObjectOutputStream s) 14. throws IOException { 15. // insert code here 16. } 17. } Which code fragment, inserted at line 15, will allow Foo objects to be correctly serialized and deserialized?()
多项选择题
public class Foo { public void main (String args) { system.out.printIn(“Hello World.”); } } What is the result? ()
1. public class returnIt ( 2. returnType methodA(byte x, double y) ( 3. return (short) x/y * 2; 4. ) 5. ) What is the valid returnType for methodA in line 2?()
11. class Person { 12. String name = “No name‟; 13. public Person(String nm) { name = nm; } 14. } 15. 16. class Employee extends Person { 17. String emplD = “0000”; 18. public Employee(String id) { empID = id; } 19. } 20. 21. public class EmployeeTest { 22. public static void main(String[] args) { 23. Employee e = new Employee(”4321”); 24. System.out.println(e.empID); 25. } 26. } What is the result?()
赞题库-搜题找答案
(已有500万+用户使用)
无需下载 立即使用
版权所有©考试资料网(ppkao.com)All Rights Reserved