[Solved] Polymorphism and casting in Java [closed]


What this means is that the Manager class extends or implements the Employee class.

The second part of your question is a little unclear to me. But an example of having to cast emp is if the Manager class has a specific method which the Employee class does not. You’d need to cast emp in order to use Manager-specific methods.

Something like
((Manager) emp).managerSpecificMethod();

solved Polymorphism and casting in Java [closed]