What will be the result of compilation and execution of the following code:

package X;
public class X<X> {
    X x;
    public X(){  }
    public X(X x){ 
    public <Y extends X> Y Y(Y y){
        return y;

class Y<Y extends X> extends X{
    private static Integer Y = 5;
    public static void main(String...X){
        System.out.print(new X().Y(Y).toString());
When invoking method " public <Y extends X> Y Y(Y y)" it can receive any object as an argument. Y in this method does not have any relation to the class that was defined later in code. While instantiating X no generic type was given, so, any object can be used as an argument.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Зареєструйся Зараз
або Підпишись на майбутні тести