After 1 iteration of selection sort working on an array of 10 elements, what must hold true?
at least two elements are correctly placed
the largest element is correctly placed
one element must be correctly placed
the array cannot be sorted
In each iteration, selection sort places which element in the correct location?
the largest element in the array
the smallest element not yet placed in prior iterations
the smallest in the array
a random element
Consider an array with n elements. If we visit each element n times, how many total visits will there be?
The output of the analysis phase of the software life cycle is ____.
A description of classes and methods.
Performance measurements.
A requirements document.
Completed program code.
Which of the following statements about a Java interface is NOT true?
A Java interface specifies behavior that a class will implement.
A Java interface defines a set of methods that are required.
All methods in a Java interface must be abstract.
A Java interface must contain more than one method.
What happens when we try to add an element to a set in which the element is already present?
is replaces the duplicate
it is not added
it is added anywhere convenient
it is added after its duplicate
A linked list ____________________ encapsulates a position anywhere inside the linked list.
index
iterator
accessor
operation
What is included in a linked list node?
I a reference to the next node
II an array reference
III a data element
I
II
II and III
I and III
Which of the following statements about the software development process is true?
In the design phase, you develop a plan for how you will implement the system.
In the analysis phase, you develop a plan for how you will implement the system.
In the design phase, you write and compile program code.
In the analysis phase, you discover the structures that underlie the problem to be solved.
If a subclass contains a method with the same name as a method in its superclass, but with different parameter types, the subclass method is said to ____ the method of the superclass.
override
overload
implement
inherit
Assuming that parameter n is non-negative, what is the recursive condition of method mystery?
public int mystery (int n, int m) **
if (n == 0)
return 0;
if (n == 1)
return m;
return m + mystery(n - 1, m);
**
n == 0
n >= 2
n > 0
n == 1
Which statement is true about sets and maps?
I maps store keys and value, sets only store values
II maps store keys, sets do not
III maps and set keys are unique
What is the smallest value of n for which n2 > 3n + 4?
Which reserved word must be used to call a method of a superclass?
Which method is not part of the ListIterator class?
next
hasPrevious
previous
delete
Which of the following is not typically part of the software development process?
Analysis
Testing
Maintenance
Design
Which Java package contains the LinkedList class?
java.collections
java.util
java.io
java.lang
When a recursive method is called, and it does not perform recursion, what must be true?
the terminating condition was true
all recursive case conditions were true
one recursive case condition was true
an exception will occur in the method
Consider the getArea method from the book. Which line has the recursive case?
public int getArea()
**
if (width <= 0) return 0; // line #1
if (width == 1) return 1; // line #2
Triangle smallerTriangle = new Triangle(width – 1); // line #3
int smallerArea = smallerTriangle.getArea(); // line #4
return smallerArea + width; // line #5
**
line #1
line #2
line #3
line #4
The performance of an algorithm is most closely related to what?
the total number of elements
the type of elements
the number of lines of code in the method
the total number of element visits
Which of the following methods are in the Object class?
I hashcode
II toString
III objectID
A class that represents the most general entity in an inheritance hierarchy is called a/an ____.
Default class.
Superclass
Inheritance class.
Subclass
A recursive method without a base case would ___
never terminate
not be recursive
end immediately
be more efficient
Which of the following is true regarding a class and interface types?
You can convert from a class type to any interface type that the class defines.
You cannot convert from a class type to any interface type.
You can convert from a class type to any interface type that is in the same package as the class.
You can convert from a class type to any interface type that the class implements.
When we consider an abstract view of a linked list or array list, what do we not consider?
I implementation details
II the logic of the operations
III efficiency of the operations
After 5 iterations of selection sort working on an array of 10 elements, what must hold true?
5 more iterations are always necessary to complete the sort
5 more iterations may be needed to complete the sort
4 more iterations may be needed to complete the sort
4 more iterations are always necessary to complete the sort
What are Java Set, Collection and Iterator examples of?
I generics
II classes
III interfaces
Consider the following code snippet:
public class Inventory implements Measurable
**
. . .
public double getMeasure();
**
return onHandCount;
**
**
Why is it necessary to declare getMeasure as public ?
All methods in a class are not public by default.
All methods in an interface are private by default.
It is necessary only to allow other classes to use this method.
It is not necessary to declare this method as public.
Which of the following statements about the software development process is true?
In the implementation phase, users install and use the software.
In the deployment phase, you write and compile program code.
In the deployment phase, users install and use the software.
In the implementation phase, you write and compile program code.
Which of the following is true regarding subclasses?
A subclass that inherits methods from its superclass may not override the methods.
A subclass that inherits instance variables from its superclass may not declare additional instance variables.
A subclass may inherit methods and instance variables from its superclass, and may also implement its own methods and declare its own instance variables.
A subclass may inherit methods or instance variables from its superclass but not both.
Which nodes need to be updated when we insert a new node as the fourth node from the beginning of a doubly-linked list?
the first and third nodes
the third node
the first node
the third and fourth nodes
Which Map interface method returns the keys stored in a map object?
mapKeys
keySet
getMapKeys
getKeys
To use an interface, a class header should include which of the following?
The keyword extends and the name of an abstract method in the interface
The keyword implements and the name of the interface
The keyword implements and the name of an abstract method in the interface
The keyword extends and the name of the interface
Identify the recursive condition in the following code.
int fib(int n) ** // assumes n >= 0
if (n <= 1)
return n;
else
return (fib(n - 1) + fib(n - 2));
**
fib(n – 1) + fib(n – 2)
n > 0
n < 1
n > 1
The output of the design phase of the software life cycle is ____.
Performance measurements.
A description of classes and methods.
A requirements document.
Completed program code.
A linked list allows ____________________ access, but you need to ask the list for an iterator
sequenatial
sorted
arbitrary
random
Which data structures can be used to implement a set?
I queue
II hash table
III tree
I
I and II
I and III
II and III
How many recursive calls are made from the original call to fib(4) (not counting the original call)?
int fib(int n) ** // assumes n >= 0
if (n <= 1)
return n;
else
return (fib(n - 1) + fib(n - 2));
**
What technique is used to store elements that hash to the same location?
bucketing
colliding
sharing
deletion
Consider the sort method for selection sort. Suppose we modify the loop condition to read i < a.length. What would be the result?
public void sort()
**
for (int i = 0; i < a.length – 1; i++)
**
int minPos = minimumPosition(i);
swap(minPos, i);
**
**
an exception would occur
the sort would work, but run one more iteration
the sort would work but with one less iteration
the sort would work exactly the same as before the code modification