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 } Consider the following declarations. Employee employ1 = new Employee(); Manager employ2 = new Manager(); Employee employ3 = new Manager(); Which of the following assignments is legal? I. employ1 = employ2; II. employ2 = (Manager) employ3; III. employ1 = (Manager) employ2; A. I, II, and III B. III only C. I and II only D. II only E. I only
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
}
Consider the following declarations.
Employee employ1 = new Employee();
Manager employ2 = new Manager();
Employee employ3 = new Manager();
Which of the following assignments is legal?
I. employ1 = employ2;
II. employ2 = (Manager) employ3;
III. employ1 = (Manager) employ2;
A. |
I, II, and III |
|
B. |
III only |
|
C. |
I and II only |
|
D. |
II only |
|
E. |
I only |
Trending now
This is a popular solution!
Step by step
Solved in 2 steps