Question
Consider the following complete declarations. public abstract class Player public class ComputerPlayer extends Player { { private int myCount; public ComputerPlayer() { super(); } public
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.
Step by Step Solution
3.48 Rating (164 Votes )
There are 3 Steps involved in it
Step: 1
A The code does not compile ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started