Create a package named part2. In this part, you will need to have a superclass and subclasses The superclass must have: 1. At least three variables of appropriate data type. You need to have the correct access modifiers. 2. A default constructor and an overloaded one with all the three variables. 3. The getters and setters for the variables. The subclasses must have: 1. One or two variables that are specific for each. 2. A default constructor and an overloaded one with all the variables. 3. Override the toString() method so that it prints useful information about the objects. 4. Override the equals() methods. The Test class must: 1. Create two objects from every class. 2. Call some setters and getters from the objects created. 3. Demonstrate casting from subclass to superclass (explicit casting) 4. Generate outputs demonstrating the following: a. Checking if two objects have the same contents using equals(). b. Printing out objects using toString() method. c. Showing the constructor chaining between super and sub classes
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Create a package named part2. In this part, you will need to have a superclass and subclasses
The superclass must have:
1. At least three variables of appropriate data type. You need to have the correct access
modifiers.
2. A default constructor and an overloaded one with all the three variables.
3. The getters and setters for the variables.
The subclasses must have:
1. One or two variables that are specific for each.
2. A default constructor and an overloaded one with all the variables.
3. Override the toString() method so that it prints useful information about the objects.
4. Override the equals() methods.
The Test class must:
1. Create two objects from every class.
2. Call some setters and getters from the objects created.
3. Demonstrate casting from subclass to superclass (explicit casting)
4. Generate outputs demonstrating the following:
a. Checking if two objects have the same contents using equals().
b. Printing out objects using toString() method.
c. Showing the constructor chaining between super and sub classes.
Step by step
Solved in 2 steps with 1 images