Multiple Choice
For the questions below, consider the following class definition:
public class AClass
{
protected int x;
protected int y;
public AClass(int a, int b)
{
x = a;
y = b;
}
public int addEm( )
{
return x + y;
}
public void changeEm( )
{
x++;
y--;
}
public String toString( )
{
return "" + x + " " + y;
}
}
-You want addEm to now add all three values and return the sum and changeEm to change x and y, but leave z alone. Which should you do?
A) Redefine addEm and changeEm without referencing super.addEm( ) or super.changeEm( )
B) Redefine addEm to return the value of z + super.addEm( ) , but leave changeEm alone
C) Redefine changeEm to call super.changeEm( ) and then set z = x + y, but leave addEm alone
D) Redefine addEm to return the value of z + super.addEm( ) and redefine changeEm to call super.changeEm( ) and then set z = x + y
E) Redefine changeEm to call super.changeEm( ) without doing anything to z, and redefine addEm to return super.addEm( )
Correct Answer:

Verified
Correct Answer:
Verified
Q20: If class AParentClass has a protected instance
Q31: The reserved word, extends, is used to
Q47: Interface classes cannot be extended but classes
Q52: Which of these is correct?<br>A) a base
Q53: For the questions below, assume that Poodle
Q54: A mouse event is generated by<br>A) moving
Q55: In order to implement the MouseListener interface,
Q58: What instance data and methods might you
Q60: Aside from permitting inheritance, the visibility modifier
Q61: In what manners are Timer objects similar