Question: What is wrong with line 1? public class G { private int x; public G() { x=3;} public void setX(int val){ x=val; } public String
What is wrong with line 1? public class G { private int x; public G() { x=3;} public void setX(int val){ x=val; } public String toString(){ return ""+x; } } public class H extends G { private int y; public H() { y=4;} public void setY(int val){ y=val; } public String toString() { return ""+y+super.toString(); } } //test code in the main method G bad = new H(); bad.setY(9); //line 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
