Consider the classes Food, Cheese, and Velveeta where Cheese is a subclass of Food and Velveeta is a subclass of Cheese. State which of the following lines of code are legal.

Cheese c =new Food( );
Velveeta v =new Food( );
Cheese c =new Velveeta( );
Food f =new Velveeta( );
Food f =new Cheese( );

Answers

Answer 1

Answer:

Cheese c =new Velveeta( );

Food f =new Velveeta( );

Food f =new Cheese( );

Explanation:

The super-class is the parent class from which features and attributes are inherited from while the subclass or the child class is the class inheriting from the super or parent class.

In Java, the object instance of a class is created with the syntax;

class_name instance_name = new class_name();

Food is the super or parent class of Cheese (which makes Cheese its subclass) and Cheese is the parent class of Velveeta. The extends keyword is used to denote inheritance.


Related Questions

Which view displays the records in columns and rows like excel worksheet​

Answers

Answer:

Datasheet View

Explanation:

Chapter 1

A B

Database Template A preformatted database designed for a specific purpose.

Datasheet View The Access view that displays data organized in columns and rows similar to an Excel worksheet.

Other Questions
Name 2 types of commercial protection used during menstruation and give an example of each In the figure, lines I and mare parallel lines cut by transversal p.Andrea said that if m 2 2 = 40 then m 3 must also be equal to 40. Which justifies Andrea's statement?AAlternate interior angles are congruent.B. Alternate exterior angles are congruent.C. Corresponding angles are congruent,D. Consecutive interior angles are supplementary Question 4 (1 point)Choose the best word to complete the sentence.Me seco el cuerpo conbOOOOla toallitael cepilloel peinela toalla For which topic would a live demonstration work best in a speech Select the correct answer.What was the long-term effect of the European Reformation?A. Europeans were permanently divided into two religions, Catholicism and Protestantism.OB. The political boundaries of European nations were redrawn based on religion.C. The Catholic Church divided religious authority among individual churches.D. A number of new Christian religions developed, but they had different beliefs and practices.E. Each country developed a system of government that agreed with its dominant religion. Factor completelyw^2 + 12w -f^2+ 36 HELPPPPPPPPP best answer will get braainliest An economic recession refers to __________.A.a long period of economic growthB.a sustained decline in economic outputC.a governmental policy of printing more moneyD.a short period of booming economic growth and prosperity Help pls :)))))))))))))) locking a cell so that others cannot alters its contents is know as Read this excerpt from Susan Butcher and the Iditarod Trail.Meanwhile Wild Bill faced a number of problems. The temperature had dropped to fifty degrees below zero. Speed was important, but he could not push his team too hard. The dogs' lungs might frost from breathing heavily in the Arctic air. To protect his own lungs, Bill breathed only through his nose. The bitter wind howled and hurled snow in his face. The trail was a blur.What is the best inference a reader could make from this excerpt?The only choice Bill had was to move as quickly as possible.Bill did not understand how to handle the cold Arctic weather.Moving too quickly could cause Bill and his dogs to become ill or die.Bill could not see the trail because of how quickly his team was moving. Franklin has a photographic assignment, and he needs to print some photographs using Adobe Photoshop. Which feature will help him see theprinted version of the document on the screen before he actually prints it?Thefeature in Photoshop will help Franklin see the printed version of the document on the screen before he actuallyprints it. Help me! The first person who answer this gets brainless and 15 points Help! Computer Science Discoveries. Hurry its timed What were some of the grievances people had against the government during the Civil Rights Era? (think about rights people did not have) How many hours until the charges for each company will be equal and what is that charge What is the value of x?A=2B=4C=5.5D.7 I will give out the brain thing and extra points, image below. determine the value of x , (5)(x)=0 .....................................................