Vocabulary
Arrays and ArrayLists
Strings and Substrings
OOP Concepts
Anything Goes
100

A step by step process to solve a problem or achieve a goal.

What is an algorithm?

100

Given an array arr[] of ints {3, 5, 4, 7}, what value is in arr[2]?

What is 4?

100

These two arguments are used with the overloaded form of the substring method.

What are the starting index and the ending index?

100

A collection of abstract methods and final static variables.

What is an interface?

100

What statement produces a random integer from 0 to 50, inclusive?  Your statement should store the number in an integer variable, randInt.

What is randInt = (int)(Math.random() * 51);

200

A run-time error that is thrown to indicate that the index for an array is illegal or outside the range of the array.

What is an ArrayIndexOutOfBoundsException?

200

Given an ArrayList arr of ints {3, 5, 4, 7, 6, 9, 2}, what statement would be made to return the value "7"?

What is "arr.get(3);"?

200

If String s1 = "abc"; and if String s2 = new String("abc"); what is the value of the expression if (s1 == s2)?

What is false?

[NOTE: What is the value of if (s1.equals(s2))?]


200

A cat ____ an animal, A cat ____ a color.

What are Is-a and Has-a?

200

What statement finds the real-values average of numScores, given that the sum of the scores is an integer, sum?  The average should be stored in a double variable, average.

What is 

double average = (double) sum / numScores 

OR

double average = sum / (double) numScores;?

300

A method without an implementation that acts as a placeholder.

What is an abstract method?

300

To get the number of elements in an array, you use ____; to get the number of elements in an ArrayList you use ____. (Make sure to include parentheses where necessary)

What are "length" and "size()"?

300

"abcdefgh".substring(2, 4)

What is "cd"?

300

This keyword is used in the declaration of a class when the class is going to use an interface.

What is implements?

300

Declare a two-dimensional array, mat, that can store 4 rows and 3 columns of boolean values.

What is 

boolean[][] mat = new boolean[4][3];

400

Used in object-oriented programming, this is the mechanism for combining data (variables) and behaviors (methods) into a single unit (a class).

What is encapsulation?

400

When constructing an ArrayList, you cannot use this type of variable for the ArrayList's type.

What is a primitive variable?

400

If String s1 = "car"; and if String s2 = "cat"; what is the value of the following expression:

if (s1.compareTo(s2) < 0)

[NOTE: Both the boolean value and the numeric value must be given!]

What is true (-2)?

[114 - 116 = -2 OR 18 - 20 = -2]

[This expression evaluates to true if the left-hand operand ("car") precedes the right-hand operand ("cat") in dictionary order.]

400

Given that Ship is a class with a default constructor and that Cruiser is a subclass of Ship, what is the declaration in a client class that creates a Ship object, shipObj, whose actual type is a Cruiser?

What is Ship shipObj = new Cruiser();

400

Suppose an array of ints is to be sorted in decreasing order using the insertion 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?

What is 10, 8, 2, 6, 5, 13?

The insertion sort starts with the 2nd element!

Pass 1: 8, 2, 10, 6, 5, 13

Pass 2: 10, 8, 2, 6, 5, 13

500

The process whereby the appropriate the appropriate overridden method is called, not during compile time, but during run time for a particular object.

What is dynamic binding?

500

This is the primary reason one would use an ArrayList over an Array.

What is dynamic resizing? (Or the ability to add elements/remove elements/change size/etc.)

500

If String s1 = "brouhaha"; then the expression 

str.indexOf("ha")

will return what value?

What is 6?

[NOTE: indexOf() returns the index of the first occurrence in the string or -1 if the string is not found.]

500

If an array, arr, contains 100 Book objects and if the Book class has a getAuthor accessor method, what is the statement that stores in String str the author of the Book object in the first element of arr?

What is String str = arr[0].getAuthor();?

500

In the worst case, what is the maximum number of comparisons to search an array of 1,000 sorted integers for a given key if the most efficient sorting method is used?

What is 10?

Because the integers are sorted, the most efficient searching algorithm is the binary search.  Worst case, the key is not in the list or on an end. Binary search repeatedly cuts the list into two...round up to the nearest power of 2: 1,000 ~ 1,024 = 210