Keyword Cache
Simple Statements
Compute & Conquer
Definition Den
Algorithm Analysis
100

A primitive data type whose value is true or false. It can be used in the declaration of a variable or as the return type of a method.

boolean

100

If an array, arr, contains 100 int values, write a statement that store in int n the value of the on-hundredth element of the array.

int n = arr[99];

100

"catastrophe".substring(4, 5);

"s"

100

A Java expression that has one of two values: true or false.

Boolean

100

If sum is an int variable whose value is 12 and if amount is a double variable with value 8, what will be returned by the following statement?

return sum / amount;

1.5

200

Used in the declaration of a final variable, namely, a variable whose value cannot be changed once it has been assigned.

final

200

Suppose a double variable, cost, has been initialized. Write a statement that truncates cost to equal the highest integer that is less than or equal to cost and that stores the result in intValue.

int intValue = (int) cost;

200

The index of the last element in an array with 23 elements.

22

200

A block of code in a class used to create an object of the class. This code has no return type and cannot be invoked by a direct method call.

constructor

200

What will be the effect of executing the following code segment, given that int num1 is 0 and int num2 is 10?

if (num 1 / num2 < 0) || (num1 + num2 > 0)

   statement1;

else

   statement2;

statement1 will be executed

300

A method or variable that is declared with this word is usable only in the class in which it is declared. This means that it is not accessible to client (outside) classes.

private

300

Write a statement that finds the real-valued average of numScores scores, given that the sum of the scores is an integer, sum. The average should be stored in a variable called average.

double average = (double) sum / numScores;

300

13 / 2.0

6.5

300

This type of method retrieves information from a class object without altering that object.

accessor

300

This feature of data is used for a binary search but not necessarily for a sequential search.

sorted data

400

This type of variable or method is shared by all instances of a class, indicating that there is just one memory slot.

static

400

Write the start of an IF statement that tests whether String s2 is the same reference as String s2.

if (s1 == s2)

or

if (s2 == s1)

400

13 / 2 + 3

9

400

A compact piece of code that iterates through all the elements of a collection, always from beginning to end.

enhanced for loop


OR

for-each loop

400

If sum is an int variable whose value is 100 and if amount is an int variable with value 0, what will be returned by the following statement?

return sum / amount;

ArithmeticException

500

Used to indicate that an error has occurred; execution of the program terminates and an error message is printed.

throw

500

Consider an ArrayList<String>strList, which contains 10 strings. Write a statement that adds the String "cat" to the end of the list.

strList.add("cat");

or

strList.add(10, "cat");

500

The number of comparisons required in the worst case for a binary search of 32 sorted numbers.

6

500

An error that occurs during the execution of a program. This error halts the execution of the program and an error-message is given.

run-time error

500

Suppose an array of int is to be sroted in decreasing order using the selection sort algorithm. If the array originally contains [2, 8, 10, 6, 5, 13], what will the array look like after 2 passes of the sorting loop?

[13, 10, 8, 6, 5, 2]