Question: this is the process of taking two subclass objects, and using them to create a single data structure, and then calling a method that is

this is the process of taking two subclass objects, and using them to create a single data structure, and then calling a method that is overridden in those subclasses. Think of it like a fruit basket - it can contain fruit, which might contain apples, bananas, pears... etc, and then there might be a method called 'eat'. You wouldnt want to eat an apple the same way as a banana, since you would need to peel the banana first, but not necessarily the apple. In Java, we could think of this as an ArrayList which holds Fruit objects, and we can store Apple objects and Banana objects in that single ArrayList and then call the toString' method on the elements of the ArrayList. This is what we will do today! These are the details of the Fruit.java. Apple.java, and Banana.java classes. They will be provided for you, so you don't need to worry about them too much. You will do all of your work in the Pobjava class. These are the details of the Fruit.java, Applejava and Banana java classes.



Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!