67.7k views
2 votes
Public abstract class Playerpublic class ComputerPlayer extends Player;public class SmartComputerPlayer extends ComputerPlayer;Consider the following declarations.

I. ComputerPlayer playerA = new SmartComputerPlayer();
II. Player playerB = new SmartComputerPlayer();
III. Player playerC = new Player();

User Shae
by
5.0k points

2 Answers

5 votes

Answer:

player c

Step-by-step explanation:

User Chris Barlow
by
5.6k points
6 votes

Here's the full question;

Assume the following partial declarations have been made, with default (no parameter) constructors for the classes.

public abstract class Player

public class ComputerPlayer extends Player;

public class SmartComputerPlayer extends ComputerPlayer;

Consider the following declarations.

I. ComputerPlayer playerA = new SmartComputerPlayer();

II. Player playerB = new SmartComputerPlayer();

III. Player playerC = new Player();

Which of these declarations will compile correctly?

A.) I only

B.) II only

C.) III only

D.) I and II

E.) II and III

Answer:

C)

Explanation:

One of the rules of Java programming is that it must have a class which is a blueprint that informs about the behavior that the object of that class support.

If we go by the strict rules of Java programming only the class declaration;

Player playerC = new Player();

would compile correctly.

All other options would result in compiler error.

User Kfan
by
5.2k points