Data Structures
Which of the following is NOT a repetition control statement? 1. while 2. do-while 3. for 4. switch
Switch
Which of the following is NOT TRUE of the Stack ADT? 1. The top of the stack just be maintained 2. The bottom of the stack must be maintained 3. It should contain methods for pushing and popping data 4. It is more restrictive than the ADT Bag (Multiset)
The bottom of the stack must be maintained
Consider that there is a superclass SuperC, and its subclass, SubC. Consider that both have an implementation of a method, preparePizza(). Given the following instantiation: SuperC myVar = new SubC(); Is it true or false that SubC's version of preparePizza will be called when the call myVar.preparePizza() is made? 1. True 2. False
True
The ADT Stack must provide a getBottom() operation, which returns the element at the bottom of the Stack Object 1. True 2. False
False
To specify that a method CANNOT be overridden in a subclass, what keyword is used? 1. abstract 2. static 3. const 4. final
Final
Which of the following is NOT one of the three major categories of control structure in Java? 1. Selection 2. Repetition 3. Sequential 4. Infiltration
Infiltration
Which of the following is NOT one of the three primary principles of Object-Oriented Programming (OOP)? 1. Inheritance 2. Encapsulation 3. Instantiation 4. Polymorphism
Instantiation
The ADT Bag is also called the ADT ___. 1. List 2. Multi-set 3. Stack 4. Queue
Multi-set
The method compareTo is a method of which of the following interfaces? 1. OnClickListener 2. Comparanator 3. Serializable 4. Comparable
Comparable
Adding an item to an Array-based bag, assuming no resizing is to be done, falls into which complexity category? 1. O(n^3) 2. O(1) 3. O(n log n) 4. O(n)
O(1)
Which of the following complexity categories (Big O) represents the MOST efficient of the options provided? 1. O(log n) 2. O(n) 3. O(n^2) 4. O(2^n)
O(log n)
What is the Big O of the following code segment, given "n" is the size of an array being processed and/or the problem size? int someNum = 0; for (int i = 0; i < n; i++) { someNum += i; } 1. O(n^2) 2. O(n) 3. O(n log n) 4. O(1)
O(n)
What is the Big O of the following code segment, assuming "n" is an array size and/or the problem size? for (int i = 0; i < n; i++) { for (int j = 0; j < n/2; j++) { System.out.println("i = " + i + " and j = " + j); } } 1. O(1) 2. O(2^n) 3. O(n^3) 4. O(n^2)
O(n^2)
Given the following infix expression: a * b / c + d Which of the following is the corresponding postfix expression? 1. a b c * / d + 2. d c + b / a * 3. a b * c / d + 4. a b / * d +
a b * c / d +
Given the following infix expression: a + b * (c - d) What is the corresponding postfix expression? 1. a b + c d * - 2. a b c - * d + 3. a b * c - d + 4. a b c d - * +
a b c d - * +
In order to ensure that a recursive algorithm eventually terminates (stops), the algorithm must have at least one ___. 1. recursive case 2. recurrence relation 3. asymptote 4. base case
base case
Consider the following code segment: try { openFridge(); takeOutMilk(); pourMilk(); putBackMilk(); } catch (FridgeWontOpenException ex) { handleFWOE(); } catch (NoMilkException e) { handleNME(); } finally { closeFridge(); } Which of the following methods is guaranteed to run? 1. pourMilk 2. putBackMilk 3. handleNME 4. closeFridge
closeFridge
Consider a class declared thusly: public class MyClass<T> { //code goes here } Which of the following data types could this class NOT be declared to DIRECTLY hold; which of the following type parameters is invalid? 1. Double 2. float 3. String 4. Scanner
float
An ArrayList is a special type of container class of whose objects can hold various types, depending on the type parameter given when the ArrayList is declared. We call this type of class a ___. 1. generalization 2. type coercion 3. generic 4. casting
generic