多选题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: 

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


相似考题
更多“多选题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: ”相关问题
  • 第1题:

    Given the following statements:CREATE TABLE tab1 (col1 INT); CREATE TABLE tab2 (col1 INT); CREATE TRIGGER trig1 AFTER UPDATE ON tab1 REFERENCING NEW AS new1 FOR EACH ROW MODE DB2SQL INSERT INTO tab2 VALUES(new1.col1); INSERT INTO tab1 VALUES(2),(3);What is the result of the following query? SELECT count(*) FROM tab2;()

    A.3

    B.2

    C.1

    D.0


    参考答案:D

  • 第2题:

    What will be the result of attempting to compile and run the following code?()   public class Q6b0c {   public static void main(String args[]) {  int i = 4;  float f = 4.3;   double d = 1.8;   int c = 0;   if (i == f) c++;   if (((int) (f + d)) == ((int) f + (int) d))  c += 2;   System.out.println(c);   }   }  

    • A、The code will fail to compile.
    • B、0 will be written to the standard output.
    • C、1 will be written to the standard output.
    • D、2 will be written to the standard output.
    • E、3 will be written to the standard output.

    正确答案:A

  • 第3题:

    Given the following statements: CREATE TABLE tab1 (col1 INT); CREATE TABLE tab2 (col1 INT); CREATE TRIGGER trig1 AFTER UPDATE ON tab1 REFERENCING NEW AS new1 FOR EACH ROW MODE DB2SQL INSERT INTO tab2 VALUES(new1.col1); INSERT INTO tab1 VALUES(2),(3); What is the result of the following query? SELECT count(*) FROM tab2;()

    • A、3
    • B、2
    • C、1
    • D、0

    正确答案:D

  • 第4题:

    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

  • 第5题:

    Which fragment is an example of inappropriate use of assertions? ()

    • A、 assert (!(map.contains(x))); map.add(x);
    • B、 if (x > 0){}else { assert (x==0); }
    • C、 public void aMethod(int x) { assert (x > 0); }
    • D、 assert (invariantCondition()); return retval;
    • E、 switch (x) { case 1: break; case 2: creak; default: assert (x == 0);

    正确答案:C

  • 第6题:

    Which two code fragments are most likely to cause a StackOverflowError?()

    • A、int []x = {1,2,3,4,5};for(int y = 0; y < 6; y++)    System.out.println(x[y]);
    • B、static int[] x = {7,6,5,4};static { x[1] = 8;x[4] = 3; }
    • C、for(int y = 10; y < 10; y++)doStuff(y);
    • D、void doOne(int x) { doTwo(x); }void doTwo(int y) { doThree(y); }void doThree(int z) { doTwo(z); }
    • E、for(int x = 0; x < 1000000000; x++) doStuff(x);
    • F、void counter(int i) { counter(++i); }

    正确答案:D,F

  • 第7题:

    单选题
    You need to create a JSP that generates some JavaScript code to populate an array of strings used on theclient-side. Which JSP code snippet will create this array?()
    A

    MY_ARRAY = new Array();<% for ( int i = 0; i < serverArray.length; i++ ) { MY_ARRAY[<%= i %>] = ’<%= serverArray[i] %>’;} %>

    B

    MY_ARRAY = new Array();. <% for ( int i = 0; i < serverArray.length; i++ ) { . MY_ARRAY[${i}] = ’${serverArray[i]}’;. } %>

    C

    MY_ARRAY = new Array();. <% for ( int i = 0; i < serverArray.length; i++ ) { %> . MY_ARRAY[<%= i %>] = ’<%= serverArray[i] %>’;. <% } %>

    D

    MY_ARRAY = new Array();<% for ( int i = 0; i < serverArray.length; i++ ) { %> . MY_ARRAY[${i}] = ’${serverArray[i]}’;. <% } %>


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

  • 第8题:

    多选题
    Given the following class, which statements can be inserted at position 1 without causing the code to fail compilation?()   public class Q6db8 {   int a;   int b = 0;   static int c;   public void m() {   int d;   int e = 0;   // Position 1   }   }
    A

    a++;

    B

    b++;

    C

    c++;

    D

    d++;

    E

    e++;


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

  • 第9题:

    单选题
    What will be the result of attempting to compile and run the following code?()   public class Q6b0c {   public static void main(String args[]) {  int i = 4;  float f = 4.3;   double d = 1.8;   int c = 0;   if (i == f) c++;   if (((int) (f + d)) == ((int) f + (int) d))  c += 2;   System.out.println(c);   }   }
    A

    The code will fail to compile.

    B

    0 will be written to the standard output.

    C

    1 will be written to the standard output.

    D

    2 will be written to the standard output.

    E

    3 will be written to the standard output.


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

  • 第10题:

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

  • 第11题:

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


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

  • 第12题:

    单选题
    Which fragment is an example of inappropriate use of assertions? ()
    A

     assert (!(map.contains(x))); map.add(x);

    B

     if (x > 0){}else { assert (x==0); }

    C

     public void aMethod(int x) { assert (x > 0); }

    D

     assert (invariantCondition()); return retval;

    E

     switch (x) { case 1: break; case 2: creak; default: assert (x == 0);


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

  • 第13题:

    You need to create a JSP that generates some JavaScript code to populate an array of strings used on theclient-side. Which JSP code snippet will create this array?()

    • A、MY_ARRAY = new Array();<% for ( int i = 0; i < serverArray.length; i++ ) { MY_ARRAY[<%= i %>] = ’<%= serverArray[i] %>’;} %>
    • B、MY_ARRAY = new Array();. <% for ( int i = 0; i < serverArray.length; i++ ) { . MY_ARRAY[${i}] = ’${serverArray[i]}’;. } %>
    • C、MY_ARRAY = new Array();. <% for ( int i = 0; i < serverArray.length; i++ ) { %> . MY_ARRAY[<%= i %>] = ’<%= serverArray[i] %>’;. <% } %>
    • D、MY_ARRAY = new Array();<% for ( int i = 0; i < serverArray.length; i++ ) { %> . MY_ARRAY[${i}] = ’${serverArray[i]}’;. <% } %>

    正确答案:C

  • 第14题:

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

    正确答案:A,B

  • 第15题:

    Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?()   CODE FRAGMENT a:   public static void main(String args[]) {   if (args.length != 0)   System.out.println(args[args.length-1]);   }   CODE FRAGMENT b:   public static void main(String args[]) {   try { System.out.println(args[args.length]); }   catch (ArrayIndexOutOfBoundsException e) {}   }   CODE FRAGMENT c:   public static void main(String args[]) {   int ix = args.length;   String last = args[ix];   if (ix != 0) System.out.println(last);   }   CODE FRAGMENT d:   public static void main(String args[]) {   int ix = args.length-1;   if (ix > 0) System.out.println(args[ix]);   }   CODE FRAGMENT e:   public static void main(String args[]) {   try { System.out.println(args[args.length-1]);  }catch (NullPointerException e) {}   }  

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

    正确答案:A

  • 第16题:

    class Computation extends Thread {  private int num;  private boolean isComplete;  private int result;  public Computation(int num) { this.num = num; }  public synchronized void run() {  result = num * 2;  isComplete = true;  notify();  }  public synchronized int getResult() {  while (!isComplete) {  try {  wait();  } catch (InterruptedException e) { }  }  return result;  }  public static void main(String[] args) {  Computation[] computations = new Computation [4];  for (int i = 0; i < computations.length; i++) {  computations[i] = new Computation(i);  computations[i] .start();  }  for (Computation c : computations)  System.out.print(c.getResult() +“ “);  }  }  What is the result?() 

    • A、 The code will deadlock.
    • B、 The code may run with no output.
    • C、 An exception is thrown at runtime.
    • D、 The code may run with output “0 6”.
    • E、 The code may run with output “2 0 6 4‟.
    • F、 The code may ruin with output “0 2 4 6”.

    正确答案:F

  • 第17题:

    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

  • 第18题:

    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,B

  • 第19题:

    单选题
    Click the Exhibit button.   What is the result?()
    A

     The code will deadlock.

    B

     The code may run with output "2 0 6 4".

    C

     The code may run with no output.

    D

     The code may run with output "0 6".

    E

     An exception is thrown at runtime.

    F

     The code may run with output "0 2 4 6".


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


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

  • 第21题:

    单选题
    Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?()   CODE FRAGMENT a:   public static void main(String args[]) {   if (args.length != 0)   System.out.println(args[args.length-1]);   }   CODE FRAGMENT b:   public static void main(String args[]) {   try { System.out.println(args[args.length]); }   catch (ArrayIndexOutOfBoundsException e) {}   }   CODE FRAGMENT c:   public static void main(String args[]) {   int ix = args.length;   String last = args[ix];   if (ix != 0) System.out.println(last);   }   CODE FRAGMENT d:   public static void main(String args[]) {   int ix = args.length-1;   if (ix > 0) System.out.println(args[ix]);   }   CODE FRAGMENT e:   public static void main(String args[]) {   try { System.out.println(args[args.length-1]);  }catch (NullPointerException e) {}   }
    A

    Code fragment a.

    B

    Code fragment b.

    C

    Code fragment c.

    D

    Code fragment d.

    E

    Code fragment e.


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

  • 第22题:

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

    A

    B

    B

    C

    C

    D

    D


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

  • 第23题:

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

    int []x = {1,2,3,4,5};for(int y = 0; y < 6; y++)    System.out.println(x[y]);

    B

    static int[] x = {7,6,5,4};static { x[1] = 8;x[4] = 3; }

    C

    for(int y = 10; y < 10; y++)doStuff(y);

    D

    void doOne(int x) { doTwo(x); }void doTwo(int y) { doThree(y); }void doThree(int z) { doTwo(z); }

    E

    for(int x = 0; x < 1000000000; x++) doStuff(x);

    F

    void counter(int i) { counter(++i); }


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

  • 第24题:

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