Which is true? (Choose all that apply.)
-
"X extends Y" is correct if and only if X is a class and Y is an interface
-
"X extends Y" is correct if and only if X is an interface and Y is a class
-
"X extends Y" is correct if X and Y are either both classes or both interfaces
-
"X extends Y" is correct for all combinations of X and Y being classes and/or interfaces
In Java, 'extends' is used for both class inheritance and interface extension. A class can extend another class, and an interface can extend another interface. Option C correctly states that 'X extends Y' works when both are classes or both are interfaces. Options A and B are incorrect because 'extends' works in both directions (class-from-class and interface-from-interface), not just one. Option D is incorrect because a class cannot extend an interface (it implements it), and an interface cannot extend a class.