Playing Compiler—Upcasting and Downcasting
Explain why the following classes do not compile.
public class Papa { protected int x; public Papa() { x = 0; } public Papa(int y) { x = y; } } public class Daughter extends Papa { public Daughter() { } public static void main(String[] args) { Daughter d = new Papa(2); } }
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.