wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Array - I

Total questions: 10

Worksheet time: 2mins

Name
Class
Date
1.

What is an array in Java?

a)

A collection of different data types

b)

A collection of similar data types stored in a single variable

c)

A method to store data temporarily

d)

A class used to store objects

2.

Which of the following correctly declares and initializes an array?

a)

int a = {1, 2, 3};

b)

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

c)

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

d)

array a = [1, 2, 3];

3.

What is the index of the first element in a Java array?

a)

1

b)

-1

c)

0

d)

Depends on array size

4.

Which property is used to find the length of an array in Java?

a)

length()

b)

size()

c)

length

d)

count

5.

Which statement is true about Java arrays?

a)

Array size can change at runtime

b)

Arrays store different data types

c)

Array index starts from 1

d)

Arrays have fixed size

6.

Which loop is best suited to traverse an array using index?

a)

while loop

b)

if-else

c)

for loop

d)

do while

7.

What is the default value stored in an int array?

a)

null

b)

1

c)

0

d)

garbage value

8.

How many elements does the following array have?
int[] arr = {10, 20, 30, 40};

a)

3

b)

4

c)

5

d)

0

9.

What will be the output of the following code?

int[] arr = {1, 2, 3}; System.out.print(arr[1]);

a)

1

b)

2

c)

3

d)

Error

10.

What will be the output?

int[] a = new int[4];
System.out.print(a.length);

a)

0

b)

3

c)

4

d)

Error