GoConqr has a new look! Let us know what you think.

Quiz

ch_7

Joshua Villy 19 questions

Take the quiz

Questions in this quiz (19)

  1. 1Which of the following statements are correct?
    1. Achar[][] charArray = {'a', 'b'};
    2. Bchar[2][2] charArray = {{'a', 'b'}, {'c', 'd'}};
    3. Cchar[2][] charArray = {{'a', 'b'}, {'c', 'd'}};
    4. Dchar[][] charArray = {{'a', 'b'}, {'c', 'd'}};
  2. 2Assume double[][] x = new double[4][5], what are x.length and x[2].length?
    1. A4 and 4
    2. B4 and 5
    3. C5 and 4
    4. D5 and 5
  3. 3What is the index variable for the element at the first row and first column in array a?
    1. Aa[0][0]
    2. Ba[1][1]
    3. Ca[0][1]
    4. Da[1][0]
  4. 4When you create an array using the following statement, the element values are automatically initialized to 0.

    int[][] matrix = new int[5][5];
    1. ATrue
    2. BFalse
  5. 5How many elements are array matrix (int[][] matrix = new int[5][5])?
    1. A14
    2. B20
    3. C25
    4. D30
  6. 6Analyze 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]);
    }
    }
    1. AThe program has a compile error because new boolean[3][] is wrong.
    2. BThe program has a runtime error because x[2][2] is null.
    3. CThe program runs and displays x[2][2] is null.
    4. DThe program runs and displays x[2][2] is true.
    5. EThe program runs and displays x[2][2] is false.
  7. 7Assume int[][] x = {{1, 2}, {3, 4}, {5, 6}}, what are x.length are x[0].length?
    1. A2 and 1
    2. B2 and 2
    3. C3 and 2
    4. D2 and 3
    5. E3 and 3
  8. 8Assume int[][] x = {{1, 2}, {3, 4, 5}, {5, 6, 5, 9}}, what are x[0].length, x[1].length, and x[2].length?
    1. A2, 3, and 3
    2. B2, 3, and 4
    3. C3, 3, and 3
    4. D3, 3, and 4
    5. E2, 2, and 2
  9. 9 What will be displayed by the following program?

    public class Test {
    public static void main(String[] args) {
    int[][] values = {{3, 4, 5, 1}, {33, 6, 1, 2}};

    int v = values[0][0];
    for (int row = 0; row < values.length; row++)
    for (int column = 0; column < values[row].length; column++)
    if (v < values[row][column])
    v = values[row][column];

    System.out.print(v);
    }
    }
    1. A1
    2. B3
    3. C5
    4. D6
    5. E33
  10. 10What will be displayed by the following program?

    public class Test {
    public static void main(String[] args) {
    int[][] values = {{3, 4, 5, 1}, {33, 6, 1, 2}};

    int v = values[0][0];
    for (int[] list : values)
    for (int element : list)
    if (v > element)
    v = element;

    System.out.print(v);
    }
    }
    1. A1
    2. B3
    3. C5
    4. D6
    5. E33

Information

Description
Chapter 7
Language
English
Views
834
Rating
No ratings yet
Rate this quiz
Rate this quiz

Feedback

What is it about?

What do you think of the new look?

How do you like it?