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
Q1: Which of the following is an example
Q2: A variable declared to be of one
Q3: Which of the following is True regarding
Q4: In order to determine the type that
Q7: For the questions below, use the following
Q8: For the questions below, consider the following
Q9: For the questions below, consider the following
Q11: For the questions below, use the following
Q25: Inheritance through an extended (derived) class supports
Q40: Two children of the same parent class
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents