In c a derived class may have multiple base classes in


Java Interfaces and Multiple Inheritance

In C++, a derived class may have multiple base classes. In contrast, a Java derived class may only have one base class but may implement more than one interface. This question asks you to compare these two language designs.

(a) Draw a C++ class hierarchy with multiple inheritance using the following classes:

Pizza, for a class containing all kinds of pizza,

Meat, for pizza that has meat topping,

Vet, for pizza that has vegetable topping, Sausage, for pizza that has sausage topping, Ham, for pizza that has ham topping, Pineapple, for pizza that has pineapple topping,

Mushroom, for pizza that has mushroom topping,

Hawaiian, for pizza that has ham and pineapple topping.

For simplicity, treat sausage and ham as meats and pineapple and mushroom as vegetables.

(b) If you were to implement these classes in C++ for some kind of pizza- manufacturing robot, what kind of potential con?icts associated with multiple inheritance might you have to resolve?

(c) If you were to represent this hierarchy in Java, which would you de?ne as interfaces and which as classes? Write your answer by carefully redrawing your picture, identifying which are classes and which are interfaces. If your program creates objects of each type, you may need to add some additional classes. Include these in your drawing.

(d) Give an advantage of C++ multiple inheritance over Java classes and interfaces and one advantage of the Java design over C++.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: In c a derived class may have multiple base classes in
Reference No:- TGS01269988

Expected delivery within 24 Hours