Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment: Write Java program where it contains the following: Three classes: 1 superclass and 2 subclasses. You can reuse the class of your assignment 1

Assignment:
Write Java program where it contains the following:
Three classes: 1 superclass and 2 subclasses. You can reuse the class of your assignment
1 as one of the three classes;
The 2 subclasses inherit the superclass;
A main class (main program) to create 2 instances, 1 instance per each class. And then
output the values of all the properties (attributes) to the console. An example main
program is given for your reference.
Basic Requirement:
You need to submit 4. java files: one per each class and one for the main class;
Write your classes under a package named assign2;
Use the name convention: Assign2_pXXXXXXX as the class name of your main
No inner classes (e.g. a class declared in the main class);
For the superclass:
Define 2 properties of the class;
The 2 properties must be common properties of the 2 subclasses;
Override the toString() method to output the values of all the properties;
For the subclasses:
Define 2 additional properties of per each subclass;
The 2 additional properties must be specific properties of a subclass;
Override the toString() method to output the values of all the properties.
Example Code & Output:
An example main class and its output are given as follow:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions