Alessandro Camel wrote:OK, the modifiers are clear, I think my problem it's a OO problem.
Employee IS-A person, so it must have a name.
What I don't get is this :" if private variables are not inherited, in this case, how an Employee can have a name ?"
An Employee does have a name, but it's hidden in the Person part of the Employee object. Member variables and methods that are private, are only accessible inside the class itself - they are hidden from the outside, even from subclasses. By making the variable 'name' private in class Person, you are expressing that nobody outside class Person, not even the subclass Employee, needs to access the variable directly.
That's often beneficial (the principle of encapsulation): it means that the code in which the name variable is accessed, is limited to just class Person. If anything needs to change with regard to the variable (for example, you'd want to give the variable a different name or type), you only have to look in class Person and nowhere else, because you already know that class Person is the only place where 'name' is accessed directly. It makes your code easier to understand and easier to change in the future.
Subclasses in general don't need to know all the exact details of the inner workings of their superclasses.