Question: JAVA CODING: (5) (15 points) Polymorphisnm This exercise is another demonstration of polymorphism via inheritance. Note polymorphism can also be done using Composition and Interface
JAVA CODING:



(5) (15 points) Polymorphisnm This exercise is another demonstration of polymorphism via inheritance. Note polymorphism can also be done using Composition and Interface approaches. We will cover this later after the Abstraction and Interface lecture (next lecture). The base class Student provides methods (study(), party(), and sleep()) that are common to all students. The derived classes (Grad, UnderGrad, PartTime) override these methods to perform different behaviors depending on the specific type of students. For this exercise, you are using the following 3 habits for each type of students: Student Grad Do Research Sometimes Not that much Undergrad Sometimes Party hard Sleep a lot Partime Make $$ and study Party at work Part Slee Sleep at work Again no if-then-else, or switch case for student selections. In your main( program, build an array of Students [ and fill it with the three different subtype types. Use the for enhanced loop (for (Students x : stud) to walk the Students data type Your final results should look like the following: Grad: Grad students do researckh Grad parties sometime Grad students don't sleep that much UnderGrad: UnderGrad studies sometime UnderGrad tends to party hard UnderGrad tends to sleep a lot PartTime: PartTime students make $$ and study PartTime students party at work PartTime students sleep at work
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
