Question: public class G { private int x; public G() { x=3;} public void setX(int val){ x=val; } public int getX(){ return x; } } public
public class G { private int x; public G() { x=3;} public void setX(int val){ x=val; } public int getX(){ return x; } } public class H extends G { private int y; public H() { y=4;} public void setY(int val){ y=val; } public int getY(){ return y; } } Give the class declarations above and variable instantiation below, which of the following woud be valid statements? G bob = new H(); I. System.out.println( bob.x ); II. bob.setX(9); III. System.out.println( ((H)bob).getY() );
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
