Consider the following complete declarations. public abstract class Player publi
ID: 3643413 • Letter: C
Question
Consider the following complete declarations.public abstract class Player public class ComputerPlayer extends Player
{ {
private int myCount; public ComputerPlayer()
{ super(); }
public Player() }
{ myCount = 0; }
public int count() public class SmartPlayer extends ComputerPlayer
{ return myCount; } {
public int play()
public void incCount(int amt) {
incCount(2);
{ myCount += amt; } return count();
}
public abstract int play(); }
}
public class Controller
{
public void doIt()
{
Player p = new SmartPlayer();
p.play();
}
}
You compile and run these classes with a driver class that correctly calls the Controller doIt method. Which of the following best describes the outcome?
The code does not compile because an abstract class cannot have an instance variable.
*ANSWER CHOICES*
A.) The code does not compile because an abstract class cannot have an instance variable.
B.) The code does not compile because an abstract class cannot implement a method.
C.) The code does not compile because a subclass cannot access an instance variable in its superclass, either directly or indirectly.
D.) The code does not compile because the class ComputerPlayer does not implement the method play and is not declared abstract.
E.) The code does not compile because the class SmartPlayer does not define a default (no parameter) constructor.
Explanation / Answer
A.) The code does not compile because an abstract class cannot have an instance variable. This is the reason that the code does not compile
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.