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.