wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java : Array

Total questions: 10

Worksheet time: 10mins

Name
Class
Date
1.
_________________ is a collection of elements used to store the same type of data.
a)
Array
b)
Switch
c)
Case
d)
Loop
2.

What is the first index of an array?

a)

1

b)

0

c)

2

d)

3

3.
Given the following method, what would test return if
a = {0, 2, 3, 4} and v = 1?
a)
-1
b)
0
c)
1
d)
2
4.
Given the following method, what would test return if
a = {0, 2, 3, 4} and v = 3?
a)
0
b)
1
c)
2
d)
-1
5.

String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


What is the correct way to find the length of "txt" string?

a)

int len = length(txt);

b)

float len = txt.length();

c)

int len = txt.length();

d)

double len = length(txt);

6.

String x = "10";

String y = "20";

String z = x + y;

System.out.println(z);

Guess the output.

a)

1020

b)

10 20

c)

30

d)

"10 20"

7.

What will be the output of below code?


String statement = "Outfit of the day";

System.out.println(statement.Substring(3,6));

a)

it of

b)

tfit

c)

fit

d)

FIT

8.

What is the most appropriate way to check if two Strings are identical?

a)

string1 == string2

b)

string1.equals(string2)

c)

string1.same(string2)

d)

string1.equalsIgnorecase(string2)

9.

String txt = "Hello World";

System.out.println(txt.toUpperCase());


Choose the correct output.

a)

"HELLO WORLD"

b)

HELLO WORLD

c)

Hello world

d)

Hello World

10.

Java code to read elements into array studentname[ ].

a)
b)
c)
d)