Can't call method from class 1 in class 2 [closed]

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);

Leave a Comment