niusouti.com

Which two code fragments correctly create and initialize a static array of int elements()A、static final int[]a={100,200};B、static final int[]a;static{a=new int[2];a[0]=100;a[1]=200;}C、static final int[]a=new int[2]{100,200};D、static final int[]a;static v

题目

Which two code fragments correctly create and initialize a static array of int elements()

  • A、static final int[]a={100,200};
  • B、static final int[]a;static{a=new int[2];a[0]=100;a[1]=200;}
  • C、static final int[]a=new int[2]{100,200};
  • D、static final int[]a;static void int(){a=new int[3];a[0]=100;a[1]=200;}

相似考题
更多“Which two code fragments correc”相关问题
  • 第1题:

    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

  • 第2题:

    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

  • 第3题:

    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

  • 第4题:

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

  • 第5题:

    多选题
    10.publicclassBar{ 11.staticvoidfoo(int...x){ 12.//insertcodehere 13.} 14.} Which two code fragments,inserted independently at line1 2,will allow the class to compile()
    A

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

    B

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

    C

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

    D

    for(inti=0;i


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

  • 第6题:

    单选题
    Given that file is a reference to a File object that represents a directory, which code fragments will succeed in obtaining a list of the entries in the directory?()
    A

    Vector filelist = ((Directory) file).getList();

    B

    String[] filelist = file.directory();

    C

    Enumeration filelist = file.contents();

    D

    String[] filelist = file.list();

    E

    Vector filelist = (new Directory(file)).files();


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

  • 第7题:

    多选题
    Which two options can be used as traffic descriptors when classifying and marking traffic? ()
    A

    incoming interface

    B

    Layer 2 differentiated services code point (DSCP)

    C

    Layer 3 IP precedence

    D

    outgoing interface


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

  • 第8题:

    多选题
    Which two code fragments correctly create and initialize a static array of int elements?()
    A

    static final int[] a = { 100,200 };

    B

    static final int[] a; static { a=new int[2]; a[0]=100; a[1]=200; }

    C

    static final int[] a = new int[2]{ 100,200 };

    D

    static final int[] a; static void init() { a = new int[3]; a[0]=100; a[1]=200; }


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

  • 第9题:

    多选题
    The 8859-1 character code for the uppercase letter A is 65. Which of these code fragments declare and initialize a variable of type char with this value?()
    A

    char ch = 65;

    B

    char ch = ’¥65’;

    C

    char ch = ’¥0041’;

    D

    char ch = ’A’;

    E

    char ch = A;


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

  • 第10题:

    多选题
    Given that c is a reference to a valid java.io.Console object,which two code fragments read a line of textfrom the console?()
    A

    String s = c.readLine();

    B

    char[] c = c.readLine();

    C

    String s = c.readConsole();

    D

    char[] c = c.readConsole();

    E

    String s = c.readLine(%s, name );


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

  • 第11题:

    多选题
    Which two statements are true about MLP interleaving? ()
    A

    It fragments and encapsulates all packets in a fragmentation header.

    B

    Packets smaller than the fragmentation size are interleaved between the fragments of thelarger packets.

    C

    Packets larger than the fragmentation size are always fragmented, and cannot be interleaved,even if the traffic is voice traffic.

    D

    It fragments and encapsulates packets that are longer than a configured size, but does not encapsulate smaller packets inside a fragmentation header.


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

  • 第12题:

    多选题
    Which two code fragments are most likely to cause a StackOverflowError?()
    A

    A

    B

    B

    C

    C

    D

    D

    E

    E

    F

    F


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

  • 第13题:

    The 8859-1 character code for the uppercase letter A is 65. Which of these code fragments declare and initialize a variable of type char with this value?()  

    • A、char ch = 65;
    • B、char ch = ’¥65’;
    • C、char ch = ’¥0041’;
    • D、char ch = ’A’;
    • E、char ch = "A";

    正确答案:A,D

  • 第14题:

    Which code fragments will succeed in initializing a two-dimensional array named tab with a size that will cause the expression tab[3][2] to access a valid element?()   CODE FRAGMENT a:  int[][] tab = {  { 0, 0, 0 },  { 0, 0, 0 }  };   CODE FRAGMENT b:  int tab[][] = new int[4][];  for (int i=0; i   CODE FRAGMENT c:  int tab[][] = {  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0  };   CODE FRAGMENT d:  int tab[3][2];   CODE FRAGMENT e:  int[] tab[] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} };  

    • A、Code fragment a.
    • B、Code fragment b.
    • C、Code fragment c.
    • D、Code fragment d.
    • E、Code fragment e.

    正确答案:B,E

  • 第15题:

    多选题
    Click the Exhibit button.   Given: Which two statements are true if a NullPointerException is thrown on line 3 of class C?()
    A

    The application will crash.

    B

    The code on line 29 will be executed.

    C

    The code on line 5 of class A will execute.

    D

    The exception will be propagated back to line 27.

    E

    The code on line 5 of class B will execute.


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

  • 第16题:

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

  • 第17题:

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

  • 第18题:

    多选题
    Given that c is a reference to a valid java.io.Console object, which two code fragments read a line of text from the console?()
    A

    String s = c.readLine();

    B

    char[ ] c = c.readLine();

    C

    String s = c.readConsole();

    D

    char[ ] c = c.readConsole();

    E

    String s = c.readLine(%s, name );

    F

    char[ ] c = c.readLine(%s, name );


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

  • 第19题:

    多选题
    Which two code fragments correctly create and initialize a static array of int elements?()
    A

    A

    B

    B

    C

    C

    D

    D


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

  • 第20题:

    多选题
    Which code fragments will succeed in initializing a two-dimensional array named tab with a size that will cause the expression tab[3][2] to access a valid element?()   CODE FRAGMENT a:  int[][] tab = {  { 0, 0, 0 },  { 0, 0, 0 }  };   CODE FRAGMENT b:  int tab[][] = new int[4][];  for (int i=0; i   CODE FRAGMENT c:  int tab[][] = {  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0  };   CODE FRAGMENT d:  int tab[3][2];   CODE FRAGMENT e:  int[] tab[] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} };
    A

    Code fragment a.

    B

    Code fragment b.

    C

    Code fragment c.

    D

    Code fragment d.

    E

    Code fragment e.


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

  • 第21题:

    多选题
    package sun.scjp;  public enum Color { RED, GREEN, BLUE }  package sun.beta;  // insert code here  public class Beta {  Color g = GREEN;  public static void main( String[] argv)  { System.out.println( GREEN); }  }  The class Beta and the enum Color are in different packages.  Which two code fragments, inserted individually at line 2 of the Beta declaration, will allow this code to compile?()
    A

    import sun.scjp.Color.*;

    B

    import static sun.scjp.Color.*;

    C

    import sun.scjp.Color; import static sun.scjp.Color.*;

    D

    import sun.scjp.*; import static sun.scjp.Color.*;

    E

    import sun.scjp.Color; import static sun.scjp.Color.GREEN;


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

  • 第22题:

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

  • 第23题:

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

  • 第24题:

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


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