public classG<A extends X & Y & Z> regarding generics in Java

Viewed 224

I have the following statement in Java.

public classG<A extends X & Y & Z>

As this question requires knowledge about Java, I have assumed that X, Y & Z are all Java classes. But as far as I know, in Java, one class cannot extend multiple classes. Then what will be the correct assumption about X, Y & Z classes? Are all they Java interfaces?

2 Answers

The extends clause in a bound type declaration may refer to a class the generic type extends or an interface it implements. If a class is present in the list, it must come first.
So, in other words, X may be a class or an interface, while Y and Z are interfaces.

Because you can't inherit from multiple classes so the answer will be probably :
X, Y, and Z are all Java interfaces

Related