Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Misconceptions Check

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What do you use to compare Strings?

a)

=

b)

==

c)

.equals()

d)

&&

2.

What do you use to compare ints and doubles?

a)

=

b)

==

c)

.equals()

d)

||

3.

What do you use to compare chars and booleans?

a)

=

b)

==

c)

.equals()

d)

!

4.

Which of the following the correct way to initialize a String variable?

a)

string str = "Monday";

b)

String str = "Monday";

c)

String str = 'Monday';

d)

string str = 'Monday';

5.

The indexes of elements in a Java array always start with _.

a)

0

b)

1

c)

2

d)

3

6.

What is the length of this String: "Bread"

a)

2

b)

3

c)

4

d)

5

7.

What index number is the "d" in the String: "Bread"

a)

2

b)

3

c)

4

d)

5

8.

Which of the following is a situation where you SHOULD use a For Each loop?

a)

When there is no need for an index because you are just going through loop forward through each element.

b)

When you need an index so that you can tell the loop to traverse backwards through the elements.

c)

When you would like to use the index to skip around the elements in the array.

d)

When you would like to mutate (change) elements in the array.

9.

When using printf for formatting which format specifier is used for ints?

a)

%d

b)

%f

c)

%s

d)

%c

10.

When using printf for formatting which format specifier is used for doubles?

a)

%d

b)

%f

c)

%s

d)

%i

11.

public static void countCoins(int total){

}

What does this method return?

a)

An int

b)

A double

c)

A String

d)

Nothing. It is void.

12.

public static double countCoins(int sum){

}

What does this method return?

a)

An int

b)

A double

c)

A String

d)

Nothing. It is void.

13.

How can you determine the number of elements in an array?

a)

arr.length;

b)

arr.length();

c)

arr.size();

d)

arr.length - 1;

14.

How can you determine the number of elements in an ArrayList?

a)

arr.length;

b)

arr.length();

c)

arr.size();

d)

arr.length - 1;

15.

How can you determine the number of characters in a String?

a)

str.length;

b)

str.length();

c)

str.size();

d)

str.length - 1;