Example Code Ch 09-5
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;
}
}
-Refer to Example Code Ch 09-5: Which of the following would best redefine the toString method for BClass?
A) public String toString(int z)
{
Return " " + x + " " + y + " " + z;
}
B) public String toString()
{
Return super.toString() ;
}
C) public String toString()
{
Return super.toString() + " " + z;
}
D) public String toString()
{
Return super.toString() +" " x+" "+y+" "+z;
}
E) public String toString()
{
Return " " + x + " + y + " " + z;
}
Correct Answer:
Verified
Q22: Aside from permitting inheritance, the visibility modifier
Q23: Using the reserved word super, one can
A)
Q24: Java does not support multiple inheritance but
Q25: Inheritance through an extended (derived) class supports
Q26: Which of the following is an example
Q28: Which of the following is correct?
A) a
Q29: If a programmer writes a class that
Q30: Example Code Ch 09-5
Consider the following class
Q31: All classes in Java are directly or
Q32: Example Code Ch 09-5
Consider the following 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