Answered step by step
Verified Expert Solution
Question
1 Approved Answer
9.4.1. Overloading Methods Coding Exercise In the example below the greet(String who) method overloads the greet() method of Greeter. Notice that MeanGreeter inherits this method
9.4.1. Overloading Methods Coding Exercise
In the example below the greet(String who) method overloads the greet() method of Greeter. Notice that MeanGreeter inherits this method and it isnt overridden. After running the code, try overriding the greet(String) method in the MeanGreeter class to return Go away + the who String.
Greeter.java code:
Please answer the coding exercise question and fill in the code completely. Thank you!
Don't get overriding a method confused with overloading a method! Overloading a method is when several methods have the same name but the parameter types, order, or number are different. So with overriding, the method signatures look identical but they are in different classes, but in overloading, only the method names are identical and they have different parameters. 1 // overriding methods 2 g2.greet(); // This could be calling an overridden greet method in g2's class 3 g1.greet("Sam"); // This calls an overloaded greet method Coding Exercise In the example below the greet(String who) method overloads the greet() method of Greeter. Notice that MeanGreeter inherits this method and it isn't overridden. After running the code, try overriding the greet(String) method in the MeanGreeter class to return Go away + the who StringStep 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