My guess is that the variable pete
is declared as class Employee
, which means that only methods of that class can be called on that variable. You must either declare pete
as type Worker
, or use a cast:
((Worker)pete).work(5);
My guess is that the variable pete
is declared as class Employee
, which means that only methods of that class can be called on that variable. You must either declare pete
as type Worker
, or use a cast:
((Worker)pete).work(5);