Need Help ?
Have a Question ?

(Solved): (5) (15 Points) Demonstrating The Dynamic Binding Behavior (Polymorphism): Write 3 Classes With Thre ...

(5) (15 points) Demonstrating the Dynamic binding behavior (Polymorphism): Write 3 classes with three levels of hierarchy: Ba

(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

Expert Answer


Answer: I have created 4 classes - Base.java, Derive.java, D1.java and Client.java. I am also enclosing the screenshot of program execution for your reference. Please read through the comments in the
We have an Answer from Expert Buy This Answer $6