Exercise 3

1 Using Inheritance and Access Control

Write a class, Person, with the variables name, weight and ID, where ID should be protected. The next class Employed should inherit from Person and have a protected variable, salary. The last class, Programmer, contains the variables favProgLang (favorite programming language) and drinksJoltCola.


1.1




2 Question

Which protected variable(s) does the class Employed have?


2.1

salary and ID


3 A Different Exercise

Use the same class Person, but use this changed class Employed below:




Now which protected variable(s) does the class
Employed have?


3.1

name, weight, salary and ID