Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Operations Research

Authors: Frederick S. Hillier, Gerald J. Lieberman

10th edition

978-0072535105, 72535105, 978-1259162985

More Books

Students also viewed these Programming questions

Question

What are non-functional requirements? Give examples.

Answered: 1 week ago

Question

=+b) In which application is a larger length used?

Answered: 1 week ago