Menu

(Solved) : Inheritance Question 7 Arrange Following Classes Class Hierarchy Diagram Show Behaviour Sh Q32520907 . . .

Inheritance Question 7 (a) Arrange the following classes in a class hierarchy as a diagram to show where behaviour is shared and where it is extended: Person, PublicServant, Senator, Driver, President, Politician 3 marks] (b) Why would we want to inherit behaviour and state from another class? Illustrate your answer with an example that clearly shows the benefits of this approach. 3 marks] (c) You have defined a class Vehicle and now wish to define a new class HoverCraft that inherits from Vehicle and adds a single public function with this signature: void Hover Write the C+ Vehicle. Make sure that you explicitly declare the default constructor. declaration for HoverCraft that clearly shows the inheritance from 4 marks] (d) In the previous part, Vehicle has an integer variable weight defined as part of the class. What is the access modifier that must be used with weight if we want it available to HoverCraft but not to other classes that have not inherited Vehicle? [2 marks] [Total for Question 7: 12 marks]

Inheritance Question 7 (a) Arrange the following classes in a class hierarchy as a diagram to show where behaviour is shared and where it is extended: Person, PublicServant, Senator, Driver, President, Politician 3 marks] (b) Why would we want to inherit behaviour and state from another class? Illustrate your answer with an example that clearly shows the benefits of this approach. 3 marks] (c) You have defined a class Vehicle and now wish to define a new class HoverCraft that inherits from Vehicle and adds a single public function with this signature: void Hover Write the C+ Vehicle. Make sure that you explicitly declare the default constructor. declaration for HoverCraft that clearly shows the inheritance from 4 marks] (d) In the previous part, Vehicle has an integer variable weight defined as part of the class. What is the access modifier that must be used with weight if we want it available to HoverCraft but not to other classes that have not inherited Vehicle? [2 marks] [Total for Question 7: 12 marks] Show transcribed image text

Expert Answer


Answer to Inheritance Question 7 Arrange Following Classes Class Hierarchy Diagram Show Behaviour Sh Q32520907 . . .

OR