Basics
Syntax
Vocabulary
Code
Bonus
100

What is the term for a collection of elements of the same type in Java?

Array

100

What is wrong with this code?
int[] arr = {1, 2, 3, 4}

Missing semicolon at the end. 

Correct code: int[] arr = {1, 2, 3, 4};

100

What is the term for the fixed size of an array in Java?

Array length

100

What will this code output? int[] arr = {1, 2, 3}; System.out.println(arr[0]);

1

100

Can the size of a Java array be changed after it is created?

No, the size of an array in Java is fixed once initialized

200

What do you call the position of an element in an array?

Index

200

How do you assign a value of 10 to the second element of an array arr in Java?

arr[1] = 10;

200

What is an "index out of bounds" error in Java?

Accessing an array element with an invalid index

200

What will this code output? int[] arr = {4, 5, 6}; System.out.println(arr.length);

3

200

What is the return type of the Arrays.sort() method in Java?

void (It sorts the array in place)

300

What does it mean when an array is "empty" in Java?

he array has no elements or is initialized with no values.

300

How do you access the third element in an array arr in Java?

arr[2]

300

What is the term for an array with multiple dimensions, like a matrix?

Multidimensional array

300

What is wrong with this code? int[] arr = new int[5]; arr[5] = 10;

It causes an "IndexOutOfBoundsException" because the valid indices are 0 to 4.

300

What is the difference between a String[] and an int[] array in Java?

A String[] holds string values, and an int[] holds integer values.

400

What is the name of the method used to sort an array in Java?

sort()

400

What is wrong with this code?
int[] arr = new int[];

The array size or elements are missing. It should be int[] arr = new int[5]; or int[] arr = {1, 2, 3};

400

What does the clone() method do to an array in Java?

It creates a shallow copy of the array.

400

How do you fill an array with the value 5 in Java?

Arrays.fill(arr, 5);

400

How do you insert the value 50 at the second position of an array arr = {10, 20, 30, 40} in Java?

In Java, arrays have a fixed size, so you cannot directly insert into an existing array. You would need to create a new array and copy the elements.

500

What is an "index out of bounds" error in Java?

Accessing an array element with an invalid index

500

What will this code print?
int[] arr = {10, 20, 30}; System.out.println(arr[3]);

It will throw an ArrayIndexOutOfBoundsException because the index 3 is out of bounds.

500

What does it mean for an array to be "sparse" in Java?

The array contains many unused elements (often null)

500

What will this code print?
int[] arr = {10, 20, 30}; for (int i = 0; i < arr.length; i++) { System.out.println(arr[i]); }

10

20

30

500

Can you give a real-life example of how arrays are used in daily life?

A bookshelf. Each position on the shelf (index) holds a book (element), and the number of books is fixed (array size). If you have a shelf with 5 spaces, you can only store 5 books.

M
e
n
u