Midterm Review exam with verified
answers.
Practice questions for this set
Learn 1/ 7 Study with Learn
meters *= 5;
Choose matching term
1 Match the following values to the correct data type.
How can the following condition be simplified?
Note: Enter only the part inside the parenthesis, e.g. for if (a < b) you would only enter a
< b.
2 Scanner scanner = new Scanner(System.in); boolean hasKey = scanner.nextBoolean();
if (hasKey == true)
{
// some code
}
, Consider the class definition public class Package<T>. Which of the following correctly
3
instantiates the class with a generic argument of type Bottle?
Simplify the following statement using the corresponding arithmetic compound
operator.
4 meters = meters * 5;
Note: Please use a single space before and after the compound operator. Do not add
any space before the semi-colon.
Don't know?
Terms in this set (110)
Can the following statement No, it cannot be simplified. 3 multiple choice options
be simplified using one of the
arithmetic compound
operators? If so, please select
the correct statement.
float total = price + tax;
meters *= 5;
Simplify the following
statement using the
corresponding arithmetic
compound operator. meters =
meters * 5; Note: Please use
a single space before and
after the compound
operator. Do not add any
space before the semi-colon.
,Can the following statement amount += amount; 3 multiple choice options
be simplified using one of the
arithmetic compound
operators? If so, please select
the correct statement.
amount = amount + amount;
Consider the following 0
array. float[] scores =
new float[5];
What is the index of the first
element in the array?
Consider the following 4
array. float[] scores =
new float[5];
What is the index of the last
element in the array?
5
Consider the following
array. float[] scores =
new float[5];
What is the length of the
array?
, Consider the following It throws an ArrayIndexOutOfBoundsException.
code. Which of the
following answers best
describes the code?
double[] values = new
double[]{1.5, 8.2, 7.9, 3.4, 3 multiple choice options
9.9}; for (int i = 1; i <=
values.length; i++) {
System.out.println(values[i]
+ ", "); }
Consider the array below. for (int value: array) 3 multiple choice options
Which of the following choices
outputs all elements of the
array?
int[] array = {12, 98, 23, 43};
What does static mean? It means no object is necessary t o execute a method.
3 multiple choice options
The method named main is ... entry point to a program. 3 multiple choice options
the ....
Initialization is a special kind True 1 multiple choice option
of assignment.
Match the following values int 3 multiple choice options
to the correct data type.
123
Char 3 multiple choice options
Match the following values
to the correct data type.
'5'