Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the output? public abstract class Food { public void m1() { } public abstract void m2(); System.out.println(Eat.); public void printMe() { m1();

What is the output? public abstract class Food { public void m1() { } public abstract void m2();

What is the output? public abstract class Food { public void m1() { } public abstract void m2(); System.out.println("Eat."); public void printMe() { m1(); m2(); } } public class Burger extends Food { @Override public void m2() { } } public void m3() { System.out.println("Cheesy!"); } System.out. println("Fatty"); @Override public void printMe() { super.printMe(); m3(); public class Salad extends Food { @Override public void m1() { System.out.println("Healthy!"); } @Override public void m2() { System.out.println("Yummy!"); } } public class Test3 { public static void main(String[] args) { ArrayList meals = new ArrayList (); meals.add(new Salad()); meals.add(new Burger()); for (Food f : meals) f.printMe(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

The provided image contains Java code with an abstract class Food and two subclasses Salad and Burge... 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

Data Structures and Algorithms in Java

Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser

6th edition

1118771334, 1118771338, 978-1118771334

More Books

Students also viewed these Programming questions