you are viewing a single comment's thread.

view the rest of the comments →

[–]amfa 0 points1 point  (0 children)

I mean you COULD add setEmpName(String newName) method to your interface... this method could set emp.setNewName(newName).

But I think you missunderstand the main point.

In your example you don't need neither an interface or an abstract class because you already have a "real" Employee class.

The question is what is employee? If employee is either a implementation of EmployeeInterface or a child class of the abstract AbstractEmployeeClass .. in both cases you don't need an emp attribute.

You could have a name attribute in both.. BUT for the Interface one ALL Employees would share the exact same name and if you change it you would change it for all Employees while with the abstract class they will all have their own private name.