Answered step by step
Verified Expert Solution
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(); 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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started