Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The next three problems refer to the following code. Assume that Inventory objec

ID: 3772198 • Letter: T

Question

The next three problems refer to the following code. Assume that Inventory object are used to store Money and Keys objects. Public class item { public void printMe () { system.out.printIn("I am just an item"); } } public class money extends Item { public void printMe() { system.out.printIn("I am specifically money"); } } public class keys extends Item { public void printMe() { system.out.printIn(" I am specifically keys"); } } public class Inventory { private ArrayList contents = new ArrayList(); public void add(Item i) { contents.add(i); } pubic void listcontents() { for (Item i: contents) { i.printMe(); } } } Line is an example of inheritance (when cod is complied). Line is an example of poymorphism (when code is called). What will the following print: Inventory i = new Inventory(); i.add(new Money()); i.add(new keys()); i.listContents();

Explanation / Answer

0.27: 9

0.28: 2

0.29:
I am specifically money
I am specifically keys

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote