Which of the following could be inserted to fill in the blank? (Choose all that apply.)
public interface Printable { default void print() { } } class Log implements Printable { _____________________________ }
hashCode()
{ return 42; }hashCode()
{ return 42; }print()
{ }print()
{ }A, C, E.
Remember that @Override means that we are implementing a method from a superclass or interface.
The Object class declares methods with the signatures in Options A and C.
Granted, it is a poor implementation of equals()
, but it does compile.
Option E is also correct because the method is declared in Printable.
Option F is incorrect because methods from an interface are always public.
Option B is incorrect because the parameter type does not match the one in Object.
Option D is incorrect because the return type does not match the one in Object.