Front | Back |
True or False. Overridden methods must have the same argument list?
|
True. A different argument list will create an overloaded method.
|
What restrictions are there for a return type of an overridden method?
|
The return type must be the same or a sub-type of the super's method.
|
What access restrictions can a overriding method use?
|
An overridding method can be as restrictive or less. It cannot be more restrictive.
|
What are the access restriction in order from most restrictive to least?
|
1. Private
2. Package/Default 3. Protected 4. Public |
What restrictions will keep you from inheriting a method from a super class?
|
If the super method is marked, static, final, or private, it cannot be inherited. If the superclass is in another package and has Package/Default access, it cannot be inherited.
|
What restrictions are there for using exceptions in overridden methods?
|
The overridden method can throw any runtime exception. The overridden method cannot throw a checked exception if it is broader (a superclass of) or different from the checked exception declared in the superclass' method.
|
Is the ArrayIndexOutOfBoundsException a checked or runtime exception?
|
Runtime
|
Is the ClassCastException a checked or runtime exception?
|
Runtime
|
Is the IllegalArgumentException a checked or runtime exception?
|
Runtime
|
Is the IllegalStateException a checked or runtime exception?
|
Runtime
|
Is the NullPointerException a checked or runtime exception?
|
Runtime
|
Is the NumberFormatException a checked or runtime exception?
|
Runtime.
|
Why should you override the equals() method of an object?
|
The default equals method of an object returns true if the two references point to the same object. This may cause problems in collections that use Hash or in sets. (Two objects that are conceptually equal, will show up as not equal.)
|
What is the contractual relationship between the equals() method and the hash() method?
|
For two objects that return true for the equals method, the hash codes must also be equal.
|
A search of an array failed to turn up the searched for item. Instead it returns -3. What does this mean?
|
This is the "Insertion" point where the item would go if it were inserted. Insertion points are zero based, so -3 means inserting before the 4th element. (0,1,2,*,3,4,... where * is the insertion point -3.)
|