1/29
30 Q&A-style flashcards covering Java abstract classes, interfaces, one- and two-dimensional arrays, object arrays, array processing, and method parameter passing.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
A class declared with the keyword "abstract" that cannot be instantiated and may contain abstract methods as well as concrete ones.
A reference type similar to a class that can declare only static constants and abstract methods; it cannot be instantiated.
No, both abstract classes and interfaces cannot be instantiated.
An array provides a single variable name, organized contiguous storage, and efficient indexed access for all 100 objects.
A single name, elements all of the same data type, and indexed (subscript) access to each element.
Subscript (index) notation using square brackets, e.g., mark[10].
A for loop.
BaseType[] arrayName = new BaseType[length];
0 (zero).
false.
'\u0000' (the null/blank Unicode character).
null (no object reference).
An IndexOutOfBoundsException is thrown, terminating the program unless caught.
By reading mark.length
No, Java arrays are fixed length once allocated.
Read the desired size (e.g., with Scanner), then execute: int[] mark = new int[size];
double[][] payScaleTable = new double[4][5];
payScaleTable[2][1]
An array of arrays; each row is a separate one-dimensional array object.
An array capable of holding 20 Person references, all initially null; no Person objects yet exist.
A new Person object is created, and its reference is stored in element 0 of the array.
A for loop iterating from 0 to person.length – 1.
Maintain minIdx and maxIdx, iterate through the array comparing ages, updating indices when a younger or older person is found.
Set the target element (e.g., person[delIdx]) to null, leaving a "hole" in the array.
Copy the last element’s reference into the element to delete, then set the last element to null—compact but order-changing.
Use a while loop that advances until a null slot or a matching name is found, then check success or failure conditions.
The reference (address) to the array object, not a copy of the array itself.
The parameter is another reference to the same array, so the method can directly access and modify the original elements.
Yes; the reference in the caller remains unchanged and still refers to the same array object.
Provide a comma-separated list in braces, e.g., double[] reading = {5.1, 3.02, 9.65};