JAVA: The Plant class has one instance variable called name. Tree inherits from Plant and adds a height instance variable. Flower also inherits from Plant and adds a color variable. All classes have the usual constructors, accessors, mutators and toString. a) Write a Java program segment (not an entire program) that creates one array containing 2 different trees and 2 different flowers created using parameterized constructors. Include a loop that will write out the details of each object in the array. b) Can the tree object in the array call its setHeight method? Give reasons for your answer. If your answer is no, is there some way for this object to call its setHeight method?
JAVA:
The Plant class has one instance variable called name. Tree inherits from Plant and adds a height instance variable. Flower also inherits from Plant and adds a color variable. All classes have the usual constructors, accessors, mutators and toString.
a) Write a Java
b) Can the tree object in the array call its setHeight method? Give reasons for your answer. If your answer is no, is there some way for this object to call its setHeight method?
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images