Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What are the benefits of polymorphism? For example, if class B extends A, we can initialize it by A a = new B(); we can
What are the benefits of polymorphism?
For example, if class B extends A, we can initialize it by A a = new B(); we can also initialize it by B b = new B();
in Java, I usually use List list = new Arraylist rather than ArrayList list = new Arraylist, but I do now know what the advantages are.
I find some answers in google, someone says, we can create a list to add a and b if use A a = new B
but I think it also works if we create a list of A and add object b since b is a subtype of A.
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