Given:Which code, inserted at line 15, allows the class Sprite to compile?()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; }

题目
Given:Which code, inserted at line 15, allows the class Sprite to compile?()

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; }


相似考题
更多“Given:Which code, inserted at line 15, allows the class Sprite to compile?() A.Foo { public int bar() { return 1; }B.new Foo { public int bar() { return 1; }C.new Foo() { public int bar() { re”相关问题
  • 第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)  }  

    • A、Code marked with (1) is a constructor
    • B、Code marked with (2) is a constructor
    • C、Code marked with (3) is a constructor
    • D、Code marked with (4) is a constructor
    • E、Code marked with (5) is a Constructor

    正确答案:B

  • 第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?() 

    • A、 Foo { public int bar() { return 1; } }
    • B、 new Foo { public int bar() { return 1; } }
    • C、 newFoo() { public int bar(){return 1; } }
    • D、 new class Foo { public int bar() { return 1; } }

    正确答案:C

  • 第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?()

    • A、 public void foo() { }
    • B、 public int foo() { return 3; }
    • C、 public Two foo() { return this; }
    • D、 public One foo() { return this; }
    • E、 public Object foo() { return this; }

    正确答案:C,D

  • 第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?()

    • A、String x = (String) pageContext.getAttribute("foo")
    • B、String x = (String) pageContext.getRequestScope("foo")
    • C、It is NOT possible to access the pageContext object from within doStartTag
    • D、String x = (String) pageContext.getRequest().getAttribute("foo")
    • E、String x = (String) pageContext.getAttribute("foo", PageContext.ANY_SCOPE)

    正确答案:D

  • 第5题:

    int index = 1;   int foo = new int ;   int bar = foo [index];   int baz = bar + index;   What is the result?()

    • A、 Baz has the value of 0
    • B、 Baz has the value of 1
    • C、 Baz has the value of 2
    • D、 An exception is thrown.
    • E、 The code will not compile.

    正确答案:B

  • 第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?() 

    • A、 Value: 3
    • B、 Value: 8
    • C、 Value: 13
    • D、 Compilation fails.
    • E、 The code runs with no output.
    • F、 An exception is thrown at runtime.

    正确答案:A

  • 第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, ?()

    • A、 Move the line 12 print statement into the foo() method.
    • B、 Change line 7 to public synchronized void go() {.
    • C、 Change the variable declaration on line 3 to private volatile int x;.
    • D、 Wrap the code inside the foo() method with a synchronized( this ) block.
    • E、 Wrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop code here }.

    正确答案:A,D

  • 第8题:

    单选题
    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?()
    A

     Value: 3

    B

     Value: 8

    C

     Value: 13

    D

     Compilation fails.

    E

     The code runs with no output.

    F

     An exception is thrown at runtime.


    正确答案: F
    解析: 暂无解析

  • 第9题:

    多选题
    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  }
    A

    public int sum(int a, int b) { return a + b; }

    B

    public int sum(long a, long b) { return 0; }

    C

    abstract int sum();

    D

    private long sum(long a, long b) { return a + b; }

    E

    public long sum(long a, int b) { return a + b; }


    正确答案: B,C
    解析: 暂无解析

  • 第10题:

    多选题
    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?()
    A

    public void foo() { }

    B

    public int foo() { return 3; }

    C

    public Two foo() { return this; }

    D

    public One foo() { return this; }

    E

    public Object foo() { return this; }


    正确答案: C,D
    解析: 暂无解析

  • 第11题:

    单选题
    public class Test {  public static void main (String [] args)  {  string foo = “blue”;  string bar = foo;  foo = “green”;  System.out.printIn(bar);  }  }   What is the result?()
    A

     An exception is thrown.

    B

     The code will not compile.

    C

     The program prints “null”

    D

     The program prints “blue”

    E

     The program prints “green”


    正确答案: A
    解析: 暂无解析

  • 第12题:

    单选题
    int index = 1;   int foo = new int ;   int bar = foo [index];   int baz = bar + index;   What is the result?()
    A

     Baz has the value of 0

    B

     Baz has the value of 1

    C

     Baz has the value of 2

    D

     An exception is thrown.

    E

     The code will not compile.


    正确答案: E
    解析: 暂无解析

  • 第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  }  

    • A、public int sum(int a, int b) { return a + b; }
    • B、public int sum(long a, long b) { return 0; }
    • C、abstract int sum();
    • D、private long sum(long a, long b) { return a + b; }
    • E、public long sum(long a, int b) { return a + b; }

    正确答案:A,E

  • 第14题:

    Which code determines the int value foo closest to a double value bar?()  

    • A、 Int foo = (int) Math.max(bar);
    • B、 Int foo = (int) Math.min(bar);
    • C、 Int foo = (int) Math.abs(bar);
    • D、 Int foo = (int) Math.ceil(bar);
    • E、 Int foo = (int) Math.floor(bar);
    • F、 Int foo = (int) Math.round(bar);

    正确答案:F

  • 第15题:

    public class Score implements Comparable {  private int wins, losses;  public Score(int w, int 1) { wins = w; losses = 1; }  public int getWins() { return wins; }  public int getLosses() { return losses; }  public String toString() {  return “<“ + wins + “,“ + losses + “>”; }  // insert code here  }  Which method will complete this class?() 

    • A、 public int compareTo(Object o) {/*mode code here*/}
    • B、 public int compareTo(Score other) {/*more code here*/}
    • C、 public int compare(Score s1,Score s2){/*more code here*/}
    • D、 public int compare(Object o1,Object o2){/*more code here*/}

    正确答案:B

  • 第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?() 

    • A、 s.writeInt(x);
    • B、 s.serialize(x);
    • C、 s.writeObject(x);
    • D、 s.defaultWriteObject();

    正确答案:D

  • 第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?()

    • A、 Compilation fails.
    • B、 The code compiles and the output is 2.
    • C、 If lines 16, 17 and 18 were removed, compilation would fail.
    • D、 If lines 24, 25 and 26 were removed, compilation would fail.
    • E、 If lines 16, 17 and 18 were removed, the code would compile and the output would be 2.
    • F、 If lines 24, 25 and 26 were removed, the code would compile and the output would be 1.

    正确答案:B,E,F

  • 第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?()  

    • A、 public int blipvert(int x) { return 0; }
    • B、 private int blipvert(int x) { return 0; }
    • C、 private int blipvert(long x) { return 0; }
    • D、 protected long blipvert(int x, int y) { return 0; }
    • E、 protected int blipvert(long x) { return 0; }
    • F、 protected long blipvert(long x) { return 0; }
    • G、protected long blipvert(int x) { return 0; }

    正确答案:A,C,D,E,F

  • 第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?()

    • A、 public void foo() { /* more code here */ }
    • B、 private void foo() { /* more code here */ }
    • C、 protected void foo() { /* more code here */ }
    • D、 int foo() { /* more code here */ }  
    • E、 void foo() { /* more code here */ }

    正确答案:A,C,E

  • 第20题:

    单选题
    int index = 1;  int [] foo = new int [3];  int bar = foo [index];  int baz = bar + index;   What is the result?()
    A

     Baz has the value of 0

    B

     Baz has the value of 1

    C

     Baz has the value of 2

    D

     An exception is thrown.

    E

     The code will not compile.


    正确答案: C
    解析: 暂无解析

  • 第21题:

    多选题
    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?()
    A

    public int blipvert(int x) { return 0; }

    B

    private int blipvert(int x) { return 0; }

    C

    private int blipvert(long x) { return 0; }

    D

    protected long blipvert(int x, int y) { return 0; }

    E

    protected int blipvert(long x) { return 0; }

    F

    protected long blipvert(long x) { return 0; }

    G

    protected long blipvert(int x) { return 0; }


    正确答案: B,D
    解析: 暂无解析

  • 第22题:

    单选题
    Which code determines the int value foo closest to a double value bar?()
    A

     Int foo = (int) Math.max(bar);

    B

     Int foo = (int) Math.min(bar);

    C

     Int foo = (int) Math.abs(bar);

    D

     Int foo = (int) Math.ceil(bar);

    E

     Int foo = (int) Math.floor(bar);

    F

     Int foo = (int) Math.round(bar);


    正确答案: D
    解析: 暂无解析

  • 第23题:

    单选题
    Given the JSP code: 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?()
    A

    String x = (String) pageContext.getAttribute(foo)

    B

    String x = (String) pageContext.getRequestScope(foo)

    C

    It is NOT possible to access the pageContext object from within doStartTag

    D

    String x = (String) pageContext.getRequest().getAttribute(foo)

    E

    String x = (String) pageContext.getAttribute(foo, PageContext.ANY_SCOPE)


    正确答案: B
    解析: 暂无解析