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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!