Given:
interface Printable { public void print(); }
Which will compile? (Choose all that apply.)
A. public class Shape implements Printable { public void print() { } } B. public class Shape implements Printable { public void print(int x) { } } C. public class Shape implements Printable { public void print() { System.out.println("huhuhuhuh..."); } } /*from w ww . ja v a 2 s . c o m*/ D. public abstract class Shape implements Printable { public void print(int loud) { } } E. public abstract class Shape implements Printable { public void print(int loud) ; }
A, C, and D correctly implement the Printable interface.
B is incorrect because Printable's no-arg print()
method is not implemented.
E is incorrect because the overloaded print()
method is not marked abstract, AND is not implemented.