Which of the following declarations will cause a compile-time error? A. Manager employD = new Employee(); B. Employee employA = new Employee(); C. Manager employC = new Manager(); D. Programmer employE = new Programmer(); E. Employee employB = new Manager();
This questions refers to the Employee, Manager, and Programmer classes incompletely defined below.
public class Employee
{
// Constructors and other methods here
public void work()
{
System.out.println(“Employee working.”);
}
// Instance fields here
}
______________________________________________________________________________
public class Manager extends Employee
{
// Constructors and other methods here
public void work()
{
System.out.println(“Manager working.”);
}
// Instance fields here
}
______________________________________________________________________________
public class Programmer extends Employee
{
// Constructors and other methods here
public void work()
{
System.out.println(“Programmer working.”);
}
// Instance fields here
}
Which of the following declarations will cause a compile-time error?
A. |
Manager employD = new Employee(); |
|
B. |
Employee employA = new Employee(); |
|
C. |
Manager employC = new Manager(); |
|
D. |
Programmer employE = new Programmer(); |
|
E. |
Employee employB = new Manager(); |
Trending now
This is a popular solution!
Step by step
Solved in 2 steps