11. public static void test(String str) { 12. if(str == null | str.lellgth() == 0) { 13. System.out.println(”String is empty”); 14. } else { 15. System.out.println(”String is not empty”); 16. } 17. } And the invocation: 31. test(llull); What is the result?()
第1题:
11. public void addStrings(List list) { 12. list.add(”foo”); 13. list.add(”bar”); 14. } What must you change in this method to compile without warnings?()
第2题:
10. abstract public class Employee { 11. protected abstract double getSalesAmount(); 12. public double getCommision() { 13. return getSalesAmount() * 0.15; 14. } 15. } 16. class Sales extends Employee { 17. // insert method here 18. } Which two methods, inserted independently at line 17, correctly complete the Sales class?()
第3题:
A.
B.
C.
D.
E.
F.
第4题:
A
B
C
D
E
F
第5题:
11. public interface Status { 12. /* insert code here */ int MY_VALUE = 10; 13. } Which three are valid on line 12?()
第6题:
11. public class Counter { 12. public static void main(String[] args) { 13. int numArgs = /* insert code here */; 14. } 15. } and the command line: java Counter one fred 42 Which code, inserted at line 13, captures the number of arguments passed into the program?()
第7题:
A JavaBeans component has the following field: 11. private boolean enabled; Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()
第8题:
10. public class ClassA { 11. public void count(int i) { 12. count(++i); 13. } 14. } And: 20. ClassA a = new ClassA(); 21. a.count(3); Which exception or error should be thrown by the virtual machine?()
第9题:
10. class Line { 11. public class Point { public int x,y; } 12. public Point getPoint() { return new Point(); } 13. } 14. class Triangle { 15. public Triangle() { 16. // insert code here 17. } 18. } Which code, inserted at line 16, correctly retrieves a local instance of a Point object?()
第10题:
peep
bark
meow
Compilation fails.
An exception is thrown at runtime.