我可不是为了被全人类喜欢才活着的,只要对于某一个人来说|

王陸

园龄:6年11个月粉丝:2052关注:178

Java题库——chapter7 多维数组

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

本文作者:王陸

本文链接:https://www.cnblogs.com/wkfvawl/p/11594418.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   王陸  阅读(1097)  评论(0编辑  收藏  举报
历史上的今天:
2018-09-26 直接抱过来dd大牛的《背包九讲》来做笔记
2018-09-26 USACO 3.3.1 Riding the Fences 骑马修栅栏(欧拉回路)
2018-09-26 USACO 3.2.6 Sweet Butter 香甜的黄油(最短路)
2018-09-26 USACO 1.3.4 Prime Cryptarithm 牛式(模拟枚举)
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起