class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()A、 int foo() { /* more code here */ }B、 void foo() { /* more code here */ }C、 pub

题目

class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()

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

相似考题
参考答案和解析
正确答案:B,C,E
更多“class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()A、 int foo() { /* more code here */ }B、 void foo() { /* more code here */ }C、 publ”相关问题
  • 第1题:

    10. public class Bar {  11.static void foo(int...x) {  12. // insert code here  13. }  14. }  Which two code fragments, inserted independently at line 12, will allow the class to compile?()

    • A、 foreach(x) System.out.println(z);
    • B、 for(int z : x) System.out.println(z);
    • C、 while( x.hasNext()) System.out.println( x.next());
    • D、 for( int i=0; i< x.length; i++ ) System.out.println(x[i]);

    正确答案:B,D

  • 第2题:

    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

  • 第3题:

    interface A { public int getValue() }  class B implements A {  public int getValue() { return 1; }  }  class C extends B {  // insert code here  }  Which three code fragments, inserted individually at line 15, make use of polymorphism?()

    • A、 public void add(C c) { c.getValue(); }
    • B、 public void add(B b) { b.getValue(); }
    • C、 public void add(A a) { a.getValue(); }
    • D、 public void add(A a, B b) { a.getValue(); }
    • E、 public void add(C c1, C c2) { c1.getValue(); }

    正确答案:B,C,D

  • 第4题:

    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

  • 第5题:

    public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()

    • A、 public class Circle implements Shape { private int radius; }
    • B、 public abstract class Circle extends Shape { private int radius; }
    • C、 public class Circle extends Shape { private int radius; public void draw(); }
    • D、 public abstract class Circle implements Shape { private int radius; public void draw(); }
    • E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
    • F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

    正确答案:B,E

  • 第6题:

    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

  • 第7题:

    单选题
    10. interface Foo {}  11. class Alpha implements Foo {}  12. class Beta extends Alpha {}  13. class Delta extends Beta {  14. public static void main( String[] args) {  15. Beta x = new Beta();  16. // insert code here  17. }  18. }  Which code, inserted at line 16, will cause a java.lang.ClassCastException?()
    A

     Alpha a = x;

    B

     Foo f= (Delta)x;

    C

     Foo f= (Alpha)x;

    D

     Beta b = (Beta)(Alpha)x;


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

  • 第8题:

    单选题
    Given a correctly compiled class whose source code is:  package com.sun.sjcp;  public class Commander {  public static void main(String[] args) {  // more code here  }  }  Assume that the class file is located in /foo/com/sun/sjcp/, the current directory is /foo/, and that the classpath contains “.“ (current directory). Which command line correctly runs Commander?()
    A

     java Commander

    B

     java com. sim. sjcp.Commander

    C

     java com/sun/sjcp/Commander

    D

     java -cp com.sun.sjcp Commander

    E

     java -cp com/sun/sjcp Commander


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

  • 第9题:

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


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

  • 第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 abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()
    A

    public class Circle implements Shape { private int radius; }

    B

    public abstract class Circle extends Shape { private int radius; }

    C

    public class Circle extends Shape { private int radius; public void draw(); }

    D

    public abstract class Circle implements Shape { private int radius; public void draw(); }

    E

    public class Circle extends Shape { private int radius;public void draw() {/* code here */} }

    F

    public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }


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

  • 第12题:

    多选题
    Given: 3.public class MyTagHandler extends TagSupport { 4.public int doStartTag() { 5.// insert code here 6.// return an int 7.} 8.// more code here ... 18.} There is a single attribute foo in the session scope. Which three code fragments,inserted independently atline 5,return the value of the attribute?()
    A

    Object o = pageContext.getAttribute(foo);

    B

    Object o = pageContext.findAttribute(foo);

    C

    Object o = pageContext.getAttribute(foo,PageContext.SESSION_SCOPE);

    D

    HttpSession s = pageContext.getSession();Object o = s.getAttribute(foo);


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

  • 第13题:

    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

  • 第14题:

    public class Team extends java.util.LinkedList {  public void addPlayer(Player p) {  add(p);  }  public void compete(Team opponent) { /* more code here */ }  }  class Player { /* more code here */ }  Which two are true?()

    • A、 This code will compile.
    • B、 This code demonstrates proper design of an is-a relationship.
    • C、 This code demonstrates proper design of a has-a relationship.
    • D、 A Java programmer using the Team class could remove Player objects from a Team object.

    正确答案:A,D

  • 第15题:

    Given a correctly compiled class whose source code is:  package com.sun.sjcp;  public class Commander {  public static void main(String[] args) {  // more code here  }  }  Assume that the class file is located in /foo/com/sun/sjcp/, the current directory is /foo/, and that the classpath contains “.“ (current directory). Which command line correctly runs Commander?() 

    • A、 java Commander
    • B、 java com. sim. sjcp.Commander
    • C、 java com/sun/sjcp/Commander
    • D、 java -cp com.sun.sjcp Commander
    • E、 java -cp com/sun/sjcp Commander

    正确答案:B

  • 第16题:

    10. interface Foo {}  11. class Alpha implements Foo {}  12. class Beta extends Alpha {}  13. class Delta extends Beta {  14. public static void main( String[] args) {  15. Beta x = new Beta();  16. // insert code here  17. }  18. }  Which code, inserted at line 16, will cause a java.lang.ClassCastException?() 

    • A、 Alpha a = x;
    • B、 Foo f= (Delta)x;
    • C、 Foo f= (Alpha)x;
    • D、 Beta b = (Beta)(Alpha)x;

    正确答案:B

  • 第17题:

    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

  • 第18题:

    多选题
    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
    解析: 暂无解析

  • 第19题:

    多选题
    Given: Which three methods, inserted individually at line 14, will correctly complete class Two?()
    A

    int foo() { /* more code here */ }

    B

    void foo() { /* more code here */ }

    C

    public void foo() { /* more code here */ }

    D

    private void foo() { /* more code here */ }

    E

    protected void foo() { /* more code here */ }


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

  • 第20题:

    多选题
    public class Team extends java.util.LinkedList {  public void addPlayer(Player p) {  add(p);  }  public void compete(Team opponent) { /* more code here */ }  }  class Player { /* more code here */ }  Which two are true?()
    A

    This code will compile.

    B

    This code demonstrates proper design of an is-a relationship.

    C

    This code demonstrates proper design of a has-a relationship.

    D

    A Java programmer using the Team class could remove Player objects from a Team object.


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

  • 第21题:

    多选题
    class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()
    A

    int foo() { /* more code here */ }

    B

    void foo() { /* more code here */ }

    C

    public void foo() { /* more code here */ }

    D

    private void foo() { /* more code here */ }

    E

    protected void foo() { /* more code here */ }


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

  • 第22题:

    多选题
    10. public class Bar {  11.static void foo(int...x) {  12. // insert code here  13. }  14. }  Which two code fragments, inserted independently at line 12, will allow the class to compile?()
    A

    foreach(x) System.out.println(z);

    B

    for(int z : x) System.out.println(z);

    C

    while( x.hasNext()) System.out.println( x.next());

    D

    for( int i=0; i< x.length; i++ ) System.out.println(x[i]);


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

  • 第23题:

    多选题
    10. class Foo {  11. static void alpha() { /* more code here */ }  12. void beta() { /* more code here */ }  13. }  Which two are true?()
    A

    Foo.beta() is a valid invocation of beta().

    B

    Foo.alpha() is a valid invocation of alpha().

    C

    Method beta() can directly call method alpha().

    D

    Method alpha() can directly call method beta().


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