Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(5) (15 points) Demonstrating the Dynamic binding behavior (Polymorphism): Write 3 classes with three levels of hierarchy: Base, Derive (child of base), and D1 (child
(5) (15 points) Demonstrating the Dynamic binding behavior (Polymorphism): Write 3 classes with three levels of hierarchy: Base, Derive (child of base), and D1 (child of Derive class). Within each class, create a "no-arg" method with the same signature (for example void m10 ) with the exception of the D1 class. D1 class has NO m1() method defined. Each of this method (void m1()) displays the origin of the Class type. (4 points) In each of the classes, add a toString() to display the class name and their corresponding parent's class name.( 6 points / 2points each) Write a client program to demonstrate the dynamic binding behaviors by creating objects of each of the classes as well as objects of parent type with child object. In the client program, write a static method (5 points) with an argument to the Base type. You will use this static method to execute the m1() method of each of the created objects. You are NOT allowed to use object.m1() in the main() method to display the results. Explain how this demonstrates dynamic polymorphism: (minus 4 points for lack of explanation) Results: m1() from base Class: Base m1() from Derived Class: Derive from Class: Base m1() from Derived Class: Derive from Class: Base m1() from Derived Class: 01 from Class: Derive from Class: Base
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