What’s the Output?
What is the output of the following code? Give an explanation.
public class Mama { protected int x; public Mama() { x = 0; } public Mama(int y) { x = y; } } public class Daughter extends Mama { public Daughter() { } public Daughter(int x) { super(x); } public static void main(String[] args) { Daughter d = new Daughter(); System.out.println(d.x); Mama t = new Daughter(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.