True/False Indicate whether the
statement is true or false.
|
|
1.
|
There are many situations in which it is necessary to write a loop that iterates
through an array one element at a time.
|
|
2.
|
It is not possible to write a for loop that is
capable of iterating through an array of any size.
|
|
3.
|
Initializer lists cannot be used with two-dimensional arrays.
|
|
4.
|
A class can only implement one interface.
|
|
5.
|
Before sending the compareTo message to an arbitrary
object, that object must be cast to Comparable.
|
|
6.
|
When an array becomes full, insertions should not be performed.
|
|
7.
|
An ArrayList object does not track its logical
size.
|
|
8.
|
An ArrayList object can hold primitives.
|
|
9.
|
Consider the following method:
int recursiveMethod
(int n){ if (n == 1) return 1;
else return n * recursiveMethod(n - 2); }
This
recursive method would always complete its recursion.
|
|
10.
|
When a method returns, its activation record remains on the stack.
|
Multiple Choice Identify the
choice that best completes the statement or answers the question.
|
|
11.
|
Which of the following would correctly declare an array of 500 integers named
abc?
a. | int[] abc = int[500]; | c. | int[] abc = new int[499]; | b. | int abc = new int[500]; | d. | int[] abc = new
int[500]; |
|
|
12.
|
The [] operator has the same precedence as the ____ operator.
|
|
13.
|
The methods in an interface are usually ____.
a. | public | c. | protected | b. | private | d. | final |
|
|
14.
|
With the exception of the Object class, every class
has exactly one ____.
a. | interface | c. | subclass | b. | constructor | d. | superclass |
|
|
15.
|
A(n) ____ method is a method that cannot be overridden by a subclass.
a. | abstract | c. | final | b. | private | d. | concrete |
|
|
16.
|
The syntax of the statement to throw an exception is ____.
a. | throw <exception class>(); | b. | throw <exception class>(<a string>); | c. | throw new <exception class>(); | d. | throw new <exception class>(<a
string>); |
|
|
17.
|
Which of the following types of exceptions would likely be thrown if a method
parameter does not meet a precondition?
a. | ArrayIndexOutOfBoundsException | b. | IllegalArgumentException | c. | ArtithmeticException | d. | StringIndexOutOfBoundsException |
|
|
18.
|
Javadoc comments begin with ____.
|
|
19.
|
The String class’s ____ method coverts all of
the characters in a String object to lowercase.
a. | toLowerCase | c. | smallChars | b. | lowerCase | d. | lower |
|
|
20.
|
Which of the following will return the number of characters in a String object named s1?
a. | s1.length | c. | s1.length() | b. | s1.size | d. | s1.size() |
|
|
21.
|
The ArrayList method ____ returns the number of
elements currently in the list.
a. | listSize() | c. | size() | b. | numElements() | d. | length() |
|
|
22.
|
An algorithm is ____ if no work is done in the algorithm after a recursive
call.
a. | tail-recursive | c. | partially recursive | b. | head-recursive | d. | suboptimally
recursive |
|
|
23.
|
A linear search has a complexity of ____.
a. | O(log n) | c. | O(n log n) | b. | O(n) | d. | O(n2) |
|
|
24.
|
The binary search algorithm is ____.
a. | O(log n) | c. | O(n log n) | b. | O(n) | d. | O(n2) |
|
|
25.
|
For the space requirements in a recursive implementation of merge sort, ____
space is required on the call stack to support recursive calls and ____ space is used by the copy
buffer.
a. | O(n); O(log n) | c. | O(log n); O(log
n) | b. | O(n); O(n) | d. | O(log n); O(n) |
|