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

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!