Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Module 3, you learned about Java interfaces and polymorphism. In order to implement polymorphic method calls to a method named poly() which is

image text in transcribed

In Module 3, you learned about Java interfaces and polymorphism. In order to implement polymorphic method calls to a method named poly() which is declared in a superclass Super and in the direct and non-direct subclasses of Super, we must write the code in a specific way. There are also other important polymorphism facts to know, so this questions is a bit of a catch all. There are several statements below, some of which are true and the others are false. Select all of the true statements. Within the method that is generating the polymorphic method calls, the polymorphic method that gets called is the one associated with the class of the actual object that the object variable refers to, not the class of the object variable. For each subclass of Super in which we intend to polymorphically call poly(), the subclass must override poly(). If poly () is declared as abstract in Super(), then it must also be declared as abstract in every subclass of Super. In Super, poly() must be declared as an abstract method. It is legal to substitute an object of a superclass in a location where an object of one of its subclasses is declared. Polymorphism is useful because it often permits us to write much simpler and more extensible code than what we would write if Java did not support polymorphism. In Java, a polymorphic method call is implemented using a technique known as dynamic method lookup. It is legal to substitute an object of a subclass in a location where an object of its superclass is declared. For each subclass of Super in which we intend to polymorphically call poly(), the subclass must overload poly(). Within the method that is generating the polymorphic method calls, the data type of the objects on which we are making the calls will generally be Super or some subclass of Super (which is essentially acting as Super for its subclasses). Super must be declared as an abstract class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

The detailed answer for the above question is provided below Here are the true statements from the o... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting Principles Part 1

Authors: Jerry J. Weygandt, Donald E. Kieso, Paul D. Kimmel, Barbara Trenholm, Valerie Kinnear, Joan E. Barlow

6th Canadian edition

1118306783, 978-1118728918, 1118728912, 978-1118306789

More Books

Students also viewed these Programming questions