Question
JAVA 1. Implement the following classes and then write the test class that has main () method as follow: 1. Define four objects (one for
JAVA
1.Implement the following classes and then write the test class that has main () method as follow:
1. Define four objects (one for each non-abstract class).
2. Define an array of MathOp consists of 4 objects.
3. Store the objects defined in step 1 into the array defined in step 2.
4. Print the array data except the objects of type Subtraction.
Class MathOp contain one abstract method called runOperation, the other class will override previous method as follow: Read two number from the user then apply the defined operation (+, -, /, *) after that print the result.
2.Implement the Shape hierarchy shown in the below Figure, TwoDimensionalShape should contain method getArea to calculate the area of the two-dimensional shape. ThreeDimensionalShape should have methods getArea and getVolume to calculate the surface area and volume. Create a program that uses an array of Shape as reference for each object in the hierarchy. The program should print a description of the for each object in the array.
Also, in the loop that processes all shapes in the array, determine whether each shape is a TwoDimensionalShape or a ThreeDimensionalShape. If its a TwoDimensionalShape, display its area. If its a ThreeDimensionalShape, display its area and volume.
3.Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (junior or senior). Define the status as a constant. An employee has an office, salary, and date hired. A faculty member has office hours and a rank. A staff member has a title. Override the toString method in each class to display the its details in addition to class name. Write a test program that creates a Persons as reference to Student, Employee, Faculty, and Staff, and invokes their toString () methods.
Abstract) mathOp Addition Subtraction Multiplication DivisionStep 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