It asks me to define a new stack that extends ArrayList, but isn\'t that basical
ID: 3685879 • Letter: I
Question
It asks me to define a new stack that extends ArrayList, but isn't that basically what GenericStack does? Do I have to make a new class that explicitly extends ArrayList? People say that's a no no in Java but that it can be done. Please don't make the code complicated, this is only a second semester class, and I want to understand it. (Implement GenericStack using inheritance) In Listing implemented using composition. Define a new stack class that extends ArrayList Draw the UMI. diagram for the classes and then implement GenericStack Write a test program that prompts the user to enter five strings and displays them in reverse order. erExplanation / Answer
yes you need to make a new class stack that use keyword EXTENDS to inherit arralist class.
for eg something like this
yes the best practice for this would be using composition rather inheritance but this example demands you to use extend keyword.The idea is just to test your knowledge of using inheritance in general.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.