Question
1. Explain in a few sentences the inheritance relationship (parent-child) and its use. 2. Explain in a few sentences the polymorphism (child class overriding a
1. Explain in a few sentences the inheritance relationship (parent-child) and its use.
2. Explain in a few sentences the polymorphism (child class overriding a method from the parent class) and its use.
a) Write one Java class of your own with one method.
b) Write another (second) Java class that will extend the above Java class and overrides the method from the parent class.
c) Write another (third) Java class that will extend the above Java class and overrides the method from the parent class.
(In other words, these two child classes (subclasses) will override the same method of the parent class differently. It will be only a few lines of code in each Java class. Write System.out.println to demonstrate they are printing different result, and that will demonstrate that the methods in the subclasses are producing different results.)
Submit the Java code and write a few sentences to explain the expected result/output of your code.
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