Consider the following complete declarations. public abstract class Player public class ComputerPlayer extends Player { { private
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.
Introduction to Operations Research
ISBN: 978-1259162985
10th edition
Authors: Frederick S. Hillier, Gerald J. Lieberman