A.Foo { public int bar() { return 1; }
B.new Foo { public int bar() { return 1; }
C.new Foo() { public int bar() { return 1; }
D.new class Foo { public int bar() { return 1; }
第1题:
Which line contains a constructor in this class definition?() public class Counter { // (1) int current, step; public Counter(int startValue, int stepValue) { // (2) set(startValue); setStepValue(stepValue); } public int get() { return current; } // (3) public void set(int value) { current = value; } // (4) public void setStepValue(int stepValue) { step = stepValue; } // (5) }
第2题:
10. interface Foo { int bar(); } 11. public class Sprite { 12. public int fubar( Foo foo) { return foo.bar(); } 13. public void testFoo() { 14. fubar( 15. // insert code here 16.); 17. } 18. } Which code, inserted at line 15, allows the class Sprite to compile?()
第3题:
class One { public One foo() { return this; } } class Two extends One { public One foo() { return this; } } class Three extends Two { // insert method here } Which two methods, inserted individually, correctly complete the Three class?()
第4题:
Given the JSP code: <% request.setAttribute("foo", "bar"); %>and the Classic tag handler code: 5. public int doStartTag() throws JspException { 6. // insert code here 7. // return int 8. } Assume there are no other "foo" attributes in the web application. Which invocation on the pageContextobject,inserted at line 6,assigns "bar" to the variable x?()
第5题:
int index = 1; int foo = new int ; int bar = foo [index]; int baz = bar + index; What is the result?()
第6题:
public class Foo { public int a; public Foo() { a = 3; } public void addFive() { a += 5; } } and: public class Bar extends Foo { public int a; public Bar() { a = 8; } public void addFive() { this.a +=5; } } invoked with: Foo foo = new Bar(); foo.addFive(); System.out.println(”Value: “+ foo.a); What is the result?()
第7题:
public class TestFive { private int x; public void foo() { int current = x; x = current + 1; } public void go() { for(int i=0;i<5;i++) { new Thread() { public void run() { foo(); System.out.print(x + “, “); } }.start(); }}} Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ?()
第8题:
Value: 3
Value: 8
Value: 13
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第9题:
public int sum(int a, int b) { return a + b; }
public int sum(long a, long b) { return 0; }
abstract int sum();
private long sum(long a, long b) { return a + b; }
public long sum(long a, int b) { return a + b; }
第10题:
public void foo() { }
public int foo() { return 3; }
public Two foo() { return this; }
public One foo() { return this; }
public Object foo() { return this; }
第11题:
An exception is thrown.
The code will not compile.
The program prints “null”
The program prints “blue”
The program prints “green”
第12题:
Baz has the value of 0
Baz has the value of 1
Baz has the value of 2
An exception is thrown.
The code will not compile.
第13题:
Given the following code, which method declarations, when inserted at the indicated position, will not cause the program to fail compilation?() public class Qdd1f { public long sum(long a, long b) { return a + b; } // insert new method declaration here }
第14题:
Which code determines the int value foo closest to a double value bar?()
第15题:
public class Score implements Comparable
第16题:
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?()
第17题:
10. interface Foo { 11. int bar(); 12. } 13. 14. public class Beta { 15. 16. class A implements Foo { 17. public int bar() { return 1; } 18. } 19. 20. public int fubar( Foo foo) { return foo.bar(); } 21. 22. public void testFoo() { 23. 24. class A implements Foo { 25. public int bar() { return 2; } 26. } 27. 28. System.out.println( fubar( new A())); 29. } 30. 31. public static void main( String[] argv) { 32. new Beta().testFoo(); 33. } 34. } Which three statements are true?()
第18题:
1. public class Blip { 2. protected int blipvert(int x) { return 0; } 3. } 4. class Vert extends Blip { 5. // insert code here 6. } Which five methods, inserted independently at line 5, will compile?()
第19题:
Given: 10. class One { 11. void foo() { } 12. } 13. class Two extends One { 14. //insert method here 15. } Which three methods, inserted individually at line 14, will correctly complete class Two?()
第20题:
Baz has the value of 0
Baz has the value of 1
Baz has the value of 2
An exception is thrown.
The code will not compile.
第21题:
public int blipvert(int x) { return 0; }
private int blipvert(int x) { return 0; }
private int blipvert(long x) { return 0; }
protected long blipvert(int x, int y) { return 0; }
protected int blipvert(long x) { return 0; }
protected long blipvert(long x) { return 0; }
protected long blipvert(int x) { return 0; }
第22题:
Int foo = (int) Math.max(bar);
Int foo = (int) Math.min(bar);
Int foo = (int) Math.abs(bar);
Int foo = (int) Math.ceil(bar);
Int foo = (int) Math.floor(bar);
Int foo = (int) Math.round(bar);
第23题:
String x = (String) pageContext.getAttribute(foo)
String x = (String) pageContext.getRequestScope(foo)
It is NOT possible to access the pageContext object from within doStartTag
String x = (String) pageContext.getRequest().getAttribute(foo)
String x = (String) pageContext.getAttribute(foo, PageContext.ANY_SCOPE)