Question
In the following example the MeanGreeter inherits the greet() method from Greeter, but then overrides it. Run the program to see. Add another subclass called
In the following example the MeanGreeter inherits the greet() method from Greeter, but then overrides it. Run the program to see.
Add another subclass called SpanishGreeter (or another language that you know) that extends Greeter and override the greet() method to return Hola! (or hi in another language) instead of Hi!. Create an object to test it out.
please edit and fix this code IN JAVA:
public class Greeter { public String greet() { return "Hi"; }
public static void main(String[] args) { Greeter g1 = new Greeter(); System.out.println(g1.greet()); Greeter g2 = new MeanGreeter(); System.out.println(g2.greet()); } }
class MeanGreeter extends Greeter { public String greet() { return "Go Away"; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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