Search Header Logo
Unit 6  - Arrays Review

Unit 6 - Arrays Review

Assessment

Interactive Video

Computers

11th Grade

Practice Problem

Medium

Created by

Myra Deister

Used 3+ times

FREE Resource

13 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

 Which of the following statements about Java arrays is false?

Arrays can hold primitive data types and objects

The size of an array can be changed after initialization

Multi-dimensional arrays are arrays of arrays

Array elements are stored in contiguous memory locations

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is NOT a valid way to declare and initialize an array in Java?

nt[] numbers = new int[5];

int numbers[] = {1, 2, 3, 4, 5};

int[] numbers = new int[]{1, 2, 3, 4, 5};

 int numbers[5] = {1, 2, 3, 4, 5};

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following code snippet:

   int[] arr = new int[5];

   arr[5] = 10;

   What will happen when this code is executed?

The value 10 will be stored at index 5

An ArrayIndexOutOfBoundsException will be thrown

The array will automatically resize to accommodate the new element

The value 10 will be stored at index 4

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following best describes the relationship between an array's reference variable and its object in memory?

They are stored in the same memory location

The reference variable stores the first element of the array

The reference variable points to the array object on the heap

The reference variable stores the length of the array

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

 int[] a = {1, 2, 3, 4, 5};

    int[] b = a;

    b[2] = 10;

    System.out.println(a[2]);

3

10

5

An error occurs

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In the example, is it possible to use an enhanced for loop instead of a for loop?

True

False

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following code:

   int[] arr = {1, 2, 3, 4, 5};

   for(int i = 0; i < arr.length; i += 2) {

       System.out.print(arr[i] + " ");

   }

   What will be the output?

1 2 3 4 5

 1 3 5

2 4

1 3

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?