Skills101
← All practice quizzes

Quiz: Java Arrays

5 questionsNo time limitPass: 60%+10 XP on first pass

Declare and use arrays, loop over them, work with 2D arrays, use Arrays.sort / toString / fill, and write the classic array programs asked in interviews.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    public class Main {
        public static void main(String[] args) {
            int[] a = new int[4];
            System.out.println(a[2] + a.length);
        }
    }
    
  2. Question 2

    What is the last valid index of an array with length 10?

  3. Question 3

    What does this print?

    public class Main {
        public static void main(String[] args) {
            int[] a = {1, 2, 3};
            int[] b = a;
            b[0] = 9;
            System.out.println(a[0]);
        }
    }
    
  4. Question 4

    Which prints the contents of int[] nums as [1, 2, 3]?

  5. Question 5

    What does grid.length give for int[][] grid = new int[3][5];?