Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Array

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the default value of an array element of type int in Java?

a)

0

b)

null

c)

undefined

d)

0.0

2.

How do you find the length of an array in Java?

a)
  • arr.length()

b)

arr.length

c)

arr.size()

d)

arr.capacity()

3.

Which of the following is the wrong way to creates an array of strings?

a)

A) String[] arr = new String[5];

b)

B) String arr = new String[5];

c)

C) String[] arr; arr = new String[5];

d)

D) both A and C

4.

What is the output?

a)

1

b)

4

c)

3

d)

5

5.

How do you initialize an array with the values 1, 2, 3, 4, and 5?

a)

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

b)

int[] arr = new int[5]

c)

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

6.

What is the index of the first element in an array?

a)

-1

b)
  • 1

c)

0

d)

2

7.

What will the following code print?

a)

1

b)

2

c)

3

d)

4

e)

5

8.

What is the output?

a)

8

b)

11

c)

17

d)

12

9.

What is the output?

a)

[3, 4, 9, 8, 15]

b)

[2, 4, 6, 8, 10]

c)

[3, 2, 9, 4, 15]

10.

What is the answer?

a)

1

b)

3

c)

7

d)

9