Question: Consider these classes: public class Item { private int x; public void setX ( int theX ) { x = theX; } / / .

Consider these classes:
public class Item{
private int x;
public void setX(int theX){
x = theX;
}
//...other methods not shown
}
public class EnhancedItem extends Item{
private int y;
public void setY(int theY){
y = theY;
}
//...other methods not shown
}
Given the following declaration in a class other than Item or EnhancedItem:
EnhancedItem obj = new EnhancedItem();
Which of the following statements would compile?
I.
obj.y =32;
II.
obj.setY(32);
III.
obj.setX(52);

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!