多选题Given: Which four code fragments, inserted independently at line 7, will compile?()Apublic void m1() { }Bprotected void m1() { }Cprivate void m1() { }Dvoid m2() { }Epublic void m2() { }Fprotected void m2() { }

题目
多选题
Given: Which four code fragments, inserted independently at line 7, will compile?()
A

public void m1() { }

B

protected void m1() { }

C

private void m1() { }

D

void m2() { }

E

public void m2() { }

F

protected void m2() { }


相似考题
更多“多选题Given: Which four code fragments, inserted independently at line 7, will compile?()Apublic void m1() { }Bprotected void m1() { }Cprivate void m1() { }Dvoid m2() { }Epublic void m2() { }Fprotected void m2() { }”相关问题
  • 第1题:

    public class ExceptionTest {   class TestException extends Exception {}   public void runTest () throws TestException {}   public void test () /* Point X*/ {   runTest ();   }   }   At point X on line 4, which code can be added to make the code compile?()  

    • A、 Throws Exception.
    • B、 Catch (Exception e).
    • C、 Throws RuntimeException.
    • D、 Catch (TestException e).
    • E、 No code is necessary.

    正确答案:B

  • 第2题:

    1. class Alpha { void m1() {} }   2. class Beta extends Alpha { void m2() { } }   3. class Gamma extends Beta { }   4.   5. class GreekTest {   6. public static void main(String [] args) {   7. a Alpha [] a = {new Alpha(), new Beta(), new Gamma() };   8. for(Alpha a2 : a) {   9. a2.m1();   10. if (a2 instanceof Beta || a2 instanceof Gamma)   11. //insert code here   12. }   13. }   14. }   哪一行代码插入到第11行,将编译但是会在运行时产生异常?()  

    • A、 a2.m2();
    • B、 ((Beta)a2).m2();
    • C、 ((Alpha)a2).m2();
    • D、 ((Gamma)a2).m2();

    正确答案:D

  • 第3题:

    Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object.   class Base {   public void print( ) {   System.out.println("base");   }   }   class Extention extends Base {   public void print( ) {   System.out.println("extension");   // insert line of implementation here   }   }   public class Q294d {   public static void main(String args[]) {   Extention ext = new Extention( );   ext.print( );   }   }   Fill in a single line of implementation.()


    正确答案:super.print();

  • 第4题:

    Consider the following class:     class Test(int i) {     void test(int i) {  System.out.println(“I am an int.”); }    void test(String s) {   System.out.println(“I am a string.”);     }          public static void main(String args) {    Test t=new Test();     char ch=“y”;    t.test(ch);     }      }     Which of the statements below is true?()

    • A、 Line 5 will not compile, because void methods cannot be overridden.
    • B、 Line 12 will not compile, because there is no version of test() that rakes a charargument.
    • C、 The code will compile but will throw an exception at line 12.
    • D、 The code will compile and produce the following output: I am an int.
    • E、 The code will compile and produce the following output: I am a String.

    正确答案:D

  • 第5题:

    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

  • 第6题:

    多选题
    Which declarations will allow a class to be started as a standalone program?()
    A

    public void main(String args[])

    B

    public void static main(String args[])

    C

    public static main(String[] argv)

    D

    final public static void main(String [] array)

    E

    public static void main(String args[])


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

  • 第7题:

    多选题
    Which two code fragments will execute the method doStuff() in a separate thread?()
    A

    new Thread() { public void run() { doStuff(); } }

    B

    new Thread() { public void start() { doStuff(); } }

    C

    new Thread() { public void start() { doStuff(); } } .run();

    D

    new Thread() { public void run() { doStuff(); } } .start();

    E

    new Thread(new Runnable() { public void run() { doStuff(); } } ).run();

    F

    new Thread(new Runnable() { public void run() { doStuff(); } }).start();


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

  • 第8题:

    单选题
    Object类的finalize()方法是如何声明的()。
    A

    public void finalize()

    B

    protected int finalize()

    C

    C.protected void finalize(int

    D

    protected void finalize()throws Throwable


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

  • 第9题:

    多选题
    Which two code fragments will execute the method doStuff() in a separate thread?()
    A

    new Thread() {public void run() { doStuff(); }};

    B

    new Thread() {public void start() { doStuff(); }};

    C

    new Thread() {public void start() { doStuff(); }}.run();

    D

    new Thread() {public void run() { doStuff(); }}.start();

    E

    new Thread(new Runnable() {public void run() { doStuff(); }}).start();


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

  • 第10题:

    单选题
    现有:   1.  class Alpha { void m1() {} }   2.  class Beta extends Alpha { void m2() { } }   3.  class Gamma extends Beta { }   4.   5.  class GreekTest {   6.    public static void main(String [] args) {   7.      Alpha [] a = {new Alpha(), new Beta(), new Gamma() };   8.      for(Alpha a2 : a) {   9.        a2.m1();    10.       if (a2 instanceof Beta || a2 instanceof Gamma)    11.         //insert code here   12.     }    13.   }   14. }    哪一行代码插入到第11行,将编译但是会在运行时产生异常?()
    A

     a2.m2();

    B

     ((Beta)a2).m2();

    C

     ((Alpha)a2).m2();

    D

     ((Gamma)a2).m2();


    正确答案: 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题:

    多选题
    class BaseClass{  private float x= 1.0f;  protected void setVar (float f) {x = f;}  }  class SubClass extends BaseClass   {  private float x = 2.0f;  //insert code here  }   Which two are valid examples of method overriding?()
    A

    Void setVar(float f) {x = f;}

    B

    Public void setVar(int f) {x = f;}

    C

    Public void setVar(float f) {x = f;}

    D

    Public double setVar(float f) {x = f;}

    E

    Public final void setVar(float f) {x = f;}

    F

    Protected float setVar() {x=3.0f; return 3.0f; }


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

  • 第13题:

    Which two code fragments will execute the method doStuff() in a separate thread?()

    • A、 new Thread() { public void run() { doStuff(); } }
    • B、 new Thread() { public void start() { doStuff(); } }
    • C、 new Thread() { public void start() { doStuff(); } } .run();
    • D、 new Thread() { public void run() { doStuff(); } } .start();
    • E、 new Thread(new Runnable() { public void run() { doStuff(); } } ).run();
    • F、 new Thread(new Runnable() { public void run() { doStuff(); } }).start();

    正确答案:D,F

  • 第14题:

    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

  • 第15题:

    Which three will compile and run without exception?()

    • A、private synchronized Object o;
    • B、void go(){   synchronized(){/* code here */}
    • C、public synchronized void go(){/* code here */}
    • D、private synchronized(this) void go(){/* code here */}
    • E、void go(){   synchronized(Object.class){/* code here */}
    • F、void go(){   Object o = new Object();   synchronized(o){/* code here */}

    正确答案:C,E,F

  • 第16题:

    Which two code fragments will execute the method doStuff() in a separate thread?()

    • A、new Thread() {public void run() { doStuff(); }};
    • B、new Thread() {public void start() { doStuff(); }};
    • C、new Thread() {public void start() { doStuff(); }}.run();
    • D、new Thread() {public void run() { doStuff(); }}.start();
    • E、new Thread(new Runnable() {public void run() { doStuff(); }}).start();

    正确答案:D,E

  • 第17题:

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

  • 第18题:

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

  • 第19题:

    多选题
    Given: Which five methods, inserted independently at line 5, will compile?()
    A

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

    B

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

    C

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

    D

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

    E

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

    F

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

    G

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


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

  • 第20题:

    多选题
    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(); }


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

  • 第21题:

    多选题
    public class X {  public X aMethod() { return this;}  }  public class Y extends X {  }  Which two methods can be added to the definition of class Y?()
    A

    public void aMethod() {}

    B

    private void aMethod() {}

    C

    public void aMethod(String s) {}

    D

    private Y aMethod() { return null; }

    E

    public X aMethod() { return new Y(); }


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

  • 第22题:

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

  • 第23题:

    单选题
    What code, inserted at line 21, is called prior to a session being migrated to a different JVM assuming the web application containing MyExample is deployed in a container which supports distributed applications?()
    A

     public void valueUnbound(HttpSessionEvent ev){...}

    B

     public void sessionPassivated(HttpSessionEvent ev){...}

    C

     public void sessionDidActivate(HttpSessionEvent ev){...}

    D

     public void sessionWillPassivate(HttpSessionEvent ev){...}


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