1. A search algorithm
Arranges elements in descending order
Arranges elements in ascending order
Is a way to locate a specific item in a larger collection of data
Is rarely used with arrays
1. Given that String str has been initialized, to get a copy of str with all characters converted to upper case, use the following statement
1. If lower is the first subscript in a contiguous portion of an array, and upper is the last subscript, then the array item in the middle of that array portion is at subscript
(lower — upper)/2
(lower + upper)/2
(upper — lower)/2
lower + upper/2
1. If a class contains an abstract method,
The method must be overridden in subclasses
You cannot create an instance of the class
The method will have only a header, but not a body, and end with a semicolon
All of the above
1. In an interface all methods have
1. In the following code, assume that inputFile references a Scanner object that has been successfully used to open a file:
double totalIncome = 0.0;
totalIncome += inputFile.nextDouble();
System.out.println(“Non-numeric data encountered ” +
“in the file.”);
totalIncome = 35.5;
What will be the value of totalIncome after the following values are read from the file?
1. The binary search algorithm
is less efficient than the sequential search algorithm
will have a maximum number of comparisons equal to the number of elements in the array
will cut the portion of the array being searched in half each time the loop fails to locate the search value
will have an average of N/2 comparisons, where N is the number of elements in the array
1. The method findMax shown below is supposed to return the position of the largest
value in the portion of an array between 0 and last, inclusive:
int findMax(int array[ ], int last)
int maxPos = 0;
for (int k = 1; k <= last; k++)
// Code is Missing
The missing code is
if (array[k] array[maxPos]) maxPos = k;
if (array[k] array[maxPos]) return maxPos;
if (array[k] maxPos) return maxPos;
if (array[k] array[maxPos]) k = maxPos;
1. The String args parameter in the main method header allows the program to receive arguments from the operating system command-line.
1. The catch clause
contains code to gracefully handle the exception type listed in the parameter list
starts with the word catch followed by a parameter list in parentheses containing an ExceptionType parameter variable
follows the try clause
All of the above
1. This ArrayList class method is used to insert an item into an ArrayList.
1. To convert the double variable, d = 543.98, to a string, use the following statement.
String str = double(d);
String str = Double.toString(d);
String str = double.toString(d);
String str = d.Double.toString(str);
1. Use the following import statement when using the Character wrapper class
No import statement is needed
1. What is the value of str after the following code has been executed?
String sourceStr = “Hey diddle, diddle, the cat and the fiddle”;
str = sourceStr.substring(12,17);
1. What is wrong with the following code?
public class ClassB extends ClassA
int init = 10;
Nothing is wrong with the code
The call to the method super must be the first statement in the constructor
No values may be passed to super
The method super is not defined
1. What will be printed when the following code is executed?
double x = 45678.259;
DecimalFormat formatter =
1. API 4.0 best describes which framework?
Ice Cream Sandwich
1. JDBC connectivity requires drivers for any database.
1. The statement below puts the app to sleep for how long?
1. Which best defines a class that takes care of creating an Android window for you in which you can place your UI?
A view component
The content provider
1. Which best describes a JDBC driver?
An interface for a Java app to interact with a database.
A class for a Java app to interact with a database.
A statement that allows for a connection to a database.
A pool of classes to allow for a connection to a database.
1. Which is not a class or interface of JDBC DriverManager?
1. Which is a proper URL connection string to connect a mysql database called sales located on your local machine in the tempdb directory in the root of the c: drive?
1. Suppose that x and y are int variables and x = 7 and y = 8. After the statement: x = x * y – 2; executes, the value of x is ____.
1. Consider a class that uses the following variables to implement an array-based stack:
The boolean method to check for an empty stack can be written as:
Bottom of Form