Choose the most correct answer to all the following questions.
Read them carefully to ensure you understand the question.
In order to perform a binary search, the source data array must be sorted.
True
False
A binary search algorithm discards one quarter of the source data after each comparison.
True
False
A bubble sort algorithm makes a number of passes through the data, comparing adjacent pairs. After the first pass, the last data item is in sorted order.
True
False
The bubble sort is the most efficient sorting algorithm available.
True
False
The String method compareTo() returns a(n)
boolean value
integer value
string value
double value
The String method equals() returns
a boolean value
an integer value
a string value
a double value
You are bubble sorting an array with 10 elements. The number of passes through the data is
1
9
10
11
The first dimension of a two dimensional array represents the _ _ _ _ _ _ _ _ _ _ _ _.
The second dimension of a two dimensional array represents the _ _ _ _ _ _ _ _ _ _ _ _ _ _ _.
int[] table = new int[5][5]; The statement table.length returns
# of rows; 5;
# of columns; 5;
# of elements; 25
none of the above
int[] table = new int[5][5]; The statement table[0].length returns _.
List the two main reasons for sorting data.
Allows for faster searches.
Visually useful when output.
To make it easier to read for the programmer.
A. and B.
Consider the following: System.out.println("a".compareTo("b")); What will be printed to the screen when the above code executes?
Consider the following: System.out.println(""a".compareTo("a")); What will be printed to the screen when the above code executes?
What method is used to wriite an object to a file?
What method is used to read an object from a file?
What is the name of the process that writes an object to a file?
What two java classes must be used to write an object to a file?