码迷,mamicode.com
首页 > 编程语言 > 详细

Java题库——chapter7 多维数组

时间:2019-09-26 21:50:59      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:stat   apt   isp   run   初始化   har   err   null   erro   

1)Which of the following statements are correct? 1) _______
A)char[ ][ ] charArray = {{‘a‘, ‘b‘}, {‘c‘, ‘d‘}};
B)char[2][2] charArray = {{‘a‘, ‘b‘}, {‘c‘, ‘d‘}};
C)char[2][ ] charArray = {{‘a‘, ‘b‘}, {‘c‘, ‘d‘}};
D)char[ ][ ] charArray = {‘a‘, ‘b‘};

二维数组静态初始化[ ][ ]不允许出现数字


2)Assume double[ ][ ] x = new double[4][5], what are x.length and x[2].length? 2) _______
A)5 and 5 B) 4 and 4 C) 5 and 4 D) 4 and 5

x.length返回该二维数组中一维数组元素的个数

x[2].length返回一维数组中元素的个数。


3)Analyze the following code:

public class Test {
  public static void main(String[ ] args) {
    boolean[ ][ ] x = new boolean[3][ ];
    x[0] = new boolean[1]; 
x[1] = new boolean[2]; x[2] = new boolean[3]; System.out.println("x[2][2] is " + x[2][2]); } }

A)The program has a runtime error because x[2][2] is null.
B)The program has a compile error because new boolean[3][ ] is wrong.
C)The program runs and displays x[2][2] is null.
D)The program runs and displays x[2][2] is true.
E)The program runs and displays x[2][2] is false.


4)Suppose a method p has the following heading:

public static int[ ][ ] p()

What return statement may be used in p()?
A)return 1;
B)return int[ ]{1, 2, 3};
C)return {1, 2, 3};
D)return new int[ ][ ]{{1, 2, 3}, {2, 4, 5}};
E)return new int[ ]{1, 2, 3};


5)Assume double[ ][ ][ ] x = new double[4][5][6], what are x.length, x[2].length, and x[0][0].length? 5) _______
A)4, 5, and 4  B) 4, 5, and 6  C)6, 5, and 4  D) 5, 5, and 5


6)Which of the following statements are correct? (Choose all that apply.) 6) _______
A)char[ ][ ][ ] charArray = new char[2][2][ ];
B)char[ ][ ][ ] charArray = {{{‘a‘, ‘b‘}, {‘c‘, ‘d‘}, {‘e‘, ‘f‘}}};
C)char[2][2][ ] charArray = {‘a‘, ‘b‘};
D)char[ ][ ][ ] charArray = {{‘a‘, ‘b‘}, {‘c‘, ‘d‘}, {‘e‘, ‘f‘}};

Java题库——chapter7 多维数组

标签:stat   apt   isp   run   初始化   har   err   null   erro   

原文地址:https://www.cnblogs.com/wkfvawl/p/11594418.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!