What happens after the compilation and execution of following code?

import java.util.*;

public class X {

    public <X> X(X x) {
        System.out.println("generic constructor");
    }

    public X(X x) {
        System.out.println("simple constructor");
    }

    public X() { }

    public static void main(String args[]) {
        X x = new X(new Integer(5));
        X x1 = new X(x);
    }
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes