WorksheetsMisconceptions Check
Total questions: 15
Worksheet time: 8mins
What do you use to compare Strings?
=
==
.equals()
&&
What do you use to compare ints and doubles?
=
==
.equals()
||
What do you use to compare chars and booleans?
=
==
.equals()
!
Which of the following the correct way to initialize a String variable?
string str = "Monday";
String str = "Monday";
String str = 'Monday';
string str = 'Monday';
The indexes of elements in a Java array always start with _.
0
1
2
3
What is the length of this String: "Bread"
2
3
4
5
What index number is the "d" in the String: "Bread"
2
3
4
5
Which of the following is a situation where you SHOULD use a For Each loop?
When there is no need for an index because you are just going through loop forward through each element.
When you need an index so that you can tell the loop to traverse backwards through the elements.
When you would like to use the index to skip around the elements in the array.
When you would like to mutate (change) elements in the array.
When using printf for formatting which format specifier is used for ints?
%d
%f
%s
%c
When using printf for formatting which format specifier is used for doubles?
%d
%f
%s
%i
public static void countCoins(int total){
}
What does this method return?
An int
A double
A String
Nothing. It is void.
public static double countCoins(int sum){
}
What does this method return?
An int
A double
A String
Nothing. It is void.
How can you determine the number of elements in an array?
arr.length;
arr.length();
arr.size();
arr.length - 1;
How can you determine the number of elements in an ArrayList?
arr.length;
arr.length();
arr.size();
arr.length - 1;
How can you determine the number of characters in a String?
str.length;
str.length();
str.size();
str.length - 1;
