Java Class Design Flashcards
What does the phrase covariant return types describe?
An overriding method can return a subtype of the return type of the overridden method.
Which type determines the version of overridden method to execute using polymoprhism?
Object type
When overloading methods, what is the order of priority for matching argument data types?
- Explicit type
- Widening primitive conversion
- Widening reference conversion
- Boxing conversion
- Unboxing conversion
When overloading methods, if all overloaded methods fail to match, which parameters are considered next?
vargs
Which the method of the Object class is invoked when placing objects in a Hashtable?
hashCode
Which two things can be referenced from a standard import statement?
Packages and types
What is the visibility of a local variable?
Only within the code block that contains its declaration
Which three access modifiers are allowed for inner classes?
public, private, protected
Which access modifier is allowed when overriding a method with the access modifier public?
public
Which primitive-to-reference conversion is not supported when using covariant return types?
Autoboxing
Which keyword is used in a subclass constructor to explicitly invoke a superclass constructor?
super
Which exception is thrown if a specified type is not a subtype of the object type in a casting operation?
ClassCastException
Which method of the Object class compares references rather than their underlying field values?
equals
Which the method of the Object class is invoked for the toString method?
hashCode
Where is a package statement required to be in a source code file?
The first executable line