What’s the Output?
What is the output of the following code? Give an explanation.
public class Papa { protected int x; public Papa() { x = 0; } public Papa(int y) { x = y; } } public class Son extends Papa { public Son() {} public Son(int x) {} public static void main(String[] args) { Son s = new Son(); System.out.println(s.x); Papa t = new Son(2); System.out.println(t.x); } }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.