Updated Study Quiz
To override a superclass method in a subclass, the subclass method ____.
A. Must use a different method name.
B. Must use the same method name and the same parameter types.
C. Must use a different method name and the same parameter types.
D. Must use a different method name and different parameter types. ANS B. must use the same method
name and the same parameter types
public interface Sizable
{
int LARGE_CHANGE = 100;
void changeSize();
}
Which of the following indicates how to use the constant LARGE_CHANGE in your program?
A. LARGE-CHANGE
B. Sizable.LARGE_CHANGE
C. Sizable(LARGE_CHANGE)
D. you cannot directly use the LARGE_CHANGE constant in your program ANS B.
Sizable.LARGE_CHANGE
public class BankAccount implements Comparable<BankAccount>
{
public int compareTo(T other)
{
What is wrong with this code?
A. the type parameter for the Comparable interface in the implements clause must be the same as the
implementing class
B. the type parameter for the Comparable interface in the implements clause must be the generic <T>
C. The type parameter for the compareTo method must be the same as the implementing class
, D. The type parameter for the compareTo interface must be the generic <T> ANS C. the type parameter for
the compareTo method must be the same as the implementing class
Which of the following statements about an interface is true?
A. an interface has methods and instance variables
B. an interface has methods but no instance variables
C. an interface has neither methods nor instance variables
D. an interface has instance variables but no methods ANS B. an interface has methods but no instance
variables
Which of the following statements about a Java interface is NOT true?
A. a Java interface defines a set of methods that are required
B. a Java interface must contain more than one method
C. a Java interface specifies behavior that a class will implement
D. all methods in a Java interface must be abstract ANS B. a Java interface must contain more than one
method
public interface Measurer
{
double measure(__________ anObject);
}
Complete this code to allow the interface to handle all classes
A. Class
B. Object
C. Any
D. Void ANS B. Object
To test whether an object belongs to a particular type, use ___________.
A. the "this" reserved word
B. the "subclassOf" reserved word
C. the "instanceOf" operator