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

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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

第2题:

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

第3题:

You need to write a code segment that transfers the first 80 bytes from a stream variable named stream1 into a new byte array named byteArray.You also need to ensure that the code segment assigns the number of bytes that are transferred to an integer variable named bytesTransferred.Which code segment should you use?()

A.bytesTransferred=stream1.Read(byteArray,0,80);

B.

C.

D.


参考答案:A

第4题:

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

第5题:

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

第6题:

Whichcodefragmentswillsucceedininitializinga&ens

Whichcodefragmentswillsucceedininitializingatwo-dimensionalarraynamedtabwithasizethatwillcausetheexpressiontab[3][2]toaccessavalidelement?()

CODEFRAGMENTa:int[][]tab={{0,0,0},{0,0,0}};

CODEFRAGMENTb:inttab[][]=newint[4][];for(inti=0;i

CODEFRAGMENTc:inttab[][]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

CODEFRAGMENTd:inttab[3][2];

CODEFRAGMENTe:int[]tab[]={{0,0,0},{0,0,0},{0,0,0},{0,0,0}};


参考答案:B, E

第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]}’;. <% } %>

正确答案:C

第8题:

有以下程序: include include usingnamespacestd; intmain() {intarrays

有以下程序: #include <iostream> #include <cstdlib> using namespace std; int main() { int arraysize; int *array; cout<<"Please input the size of the array:"; cin>>arraySiZe; array=new int[arraysize]; if(array==NULL) { cout<<"allocate Error\n"; exit(1); } for(int i=0;i<arraysize;i++) array[i]=i*i; int j; cout<<"which element you want to check:"; cin>>j; cout<<array[j]<<end1; return 0; } 执行程序输入:10<空格>5,则输出结果为( )。

A.allocate Error

B.1

C.0

D.25


正确答案:D
解析:程序中利用new()申请动态分配数组。利用for循环给数组array赋值。最后输出想要检查元素的值。程序输10,即数组array元素个数为10。程序输入5,即检查元素array[5]的值。由for循环的赋值运算可知array[5]的值为25,所以程序最后输出25。

第9题:

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

第10题:

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

更多相关问题