Multiple choice technology programming languages

What is true from the following?

  1. "X extends Y" is correct if and only if X is a class and Y is an interface

  2. "X extends Y" is correct if and only if X and Y are either both classes or both interfaces

  3. "X extends Y" is correct if and only if X is an interface and Y is a class

  4. None of these

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In Java, the extends keyword is used for both class inheritance and interface inheritance. A class can extend another class, and an interface can extend another interface, but they cannot be mixed - a class implements an interface using the implements keyword, not extends.