How can you find the length of an array within a 2d array
array[index].length
This type of exception must be handled when doing file I/O.
FileIO Exception
How many classes can a class extend?
1
What keyword is required to use an interface within a class
implements
All Java classes implicitly inherit from this class if there is no specified parent
Object
This loop type is ideal when you want to iterate through all values in an array without modifying indices.
for each
This type of reader allows you to read raw bytes from a file
FileInputStream
A method in a subclass that has the same signature but different implementation is doing this.
Overriding
Writing actual code in a method within an interface requires this keyword
default
Fields marked with this access modifier are accessible to subclasses but not to other classes.
How can you access elements of an ArrayList?
.get(index)
BufferedReader
This type of method cannot be overwritten in any subclass
final
Variables declared in Java interfaces implicitly have these charactarisitics
public static final
This operator can be used to check if an object belongs to a certain class
instanceof
This method tells you if a certain value exists within an arraylist
.contains(value)
What can you use to read objects directly from files?
ObjectInputStream
Class A has protected method getNum(), class B extends A and has public method getNum(), is this allowed?
Yes - child classes can have more accessible methods, but less accessible methods are not allowed
Can interfaces implement other interfaces?
No (The can extend other interfaces)
Where do we put code that we want to always execute, and can't be bypassed by a return
Use a loop to create a triagular array where array[0].length is 5, array[1].length is 4, and so on
int[][] triangle = new int[5][];
for (int i = 0; i < triangle.length; i++) {
triangle[i] = new int[5 - i];
}
What happens when an ObjectInputStream tries to read past the end of a file
If class B extends class A and you have an object that is of type A, how can you perform B's methods on that object?
casting
(B(objectA)).method()
If class B implements interface A, and class C extends class B, what is the relationship between C and A?
C implicitly implements A
class A {
void show() { System.out.println("A"); }
}
class B extends A {
void show() { System.out.println("B"); }
}
class Test {
public static void main(String[] args) {
A obj = new B();
obj.show();
}
}
B