Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

=+C&B (especially taxation) laws, regulations, and practices?

Answered: 1 week ago

Question

=+designing international assignment C&B packages.

Answered: 1 week ago