Java interfaces-multiple inheritance

Assignment Help JAVA Programming
Reference no: EM13963549

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++.

Reference no: EM13963549

Questions Cloud

Smith-kline company maintains inventory : Smith-Kline Company maintains inventory records at selling prices as well as at cost.
What is the tension in the support cable : A certain steam engine has an output of 500 hp and its efficiency in the use of fuel is 14%. It burns fuel oil that has a heat of combustion of 10,000 cal/g. How many kg of oil does the engine consume each hour?
Problem regarding the java bytecode analysis : One property of a Java program that is checked by the veri?er is that each object must be properly initialized before it is used. This property is fairly dif?cult to check. One relatively simple part of the analysis, however, is to guarantee that ..
The amount of the average investment for a proposed : The amount of the average investment for a proposed investment of $120,000 in a fixed asset with a useful life of 4 years, straight-line depreciation
Java interfaces-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 complete physical inventory : A complete physical inventory taken at year-end indicates only 50 units of this product actually are on hand
Find perturbation to energy of lowest-energy singlet state : Suppose that the particles interact weakly by the potential V_1(x)=Kdelta(x_1 - x_2), where x_1 and x_2 are the positions of the two particles , K is a constant, and delta is the Dirac delta function. This represents a very short-range weak force ..
Find the temperature of the steam serving : I know the efficiency of Carnot engine is 1- (T_c/T_h) and the thermal efficiency of a heat engine is 1- (Q_c/Q_h). I'm not sure how to set this up
What is the probability that the particle will be found : There are some excited states n in which the particle will never be found, no matter what values are chosen for t_1 and t_2. Which excited states are these?

Reviews

Write a Review

JAVA Programming Questions & Answers

  The implementation of a password checker

demonstrate knowledge of both exhaustive search of a problem space and lookup search through the implementation of a password checker.

  Write a java program to accept integer values

Write an algorithm, draw a flow chart and write a java program to accept integer values from keyboard and will find and print the minimum, maximum, summation and average of entered numbers when the number entered from keyboard is smaller than 1

  Convert string values from keyboard to numeric values

How do we convert string values from the keyboard to numeric values? How do we create output strings containing the values from our variables and how to answer the problem? Any help would be appreciated.

  Determine the purpose of using javascriptr on a website

write a 200- to 300-word short-answer response to the followingwhat is the purpose of using javascriptr on a website?

  Write a method in java that uses a switch statement

Write a method in JAVA that uses a switch statement and takes a person's age using an integer parameter , then checks if the age is valid (0-110), and then RETURNS a string based on the age

  Create a java application that displays the product number

Create a product class that holds the item number, the name of the product, the numberof units in stock, and the price of each unit.

  Write down several reasons why exception-handling

question 1 give several reasons why exception-handling techniques should not be used for conventional program

  Write a java application using netbeans ide

Write a Java application using NetBeans Integrated Development Environment (IDE) or jGROUP IDE that calculates the total annual compensation of a salesperson

  Problem regarding the protocol conformance

We can compare Smalltalk interfaces to classes that use protocols, which are lists of operation names (selectors). When a selector allows parameters, as in at: put: , the selector name includes the colons but not the spaces.

  Write the string copy and string concatenation functions

Write the string copy and string concatenation functions and first version should use array subscripting, and the second version should use pointer arithmetic.

  Write a java program that creates three threads

The reader-writer problem can be stated as given: A shared memory location can be concurrently read by any number of tasks, but when a task must write to the shared memory location, it must have exclusive access.

  Lydia runs a small nail salon in the town of new hope

1. Lydia runs a small nail salon in the town of New Hope. She is debating whether she should extend her hours of operation. Lydia figures that her sales revenue will depend on the number of hours the nail salon is open as shown in the table above. Sh..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd