Question: 1. Create a Shape class. The class has two String fields: the name and the size. It has a method printShapelnfo, which simply prints
1. Create a Shape class. The class has two String fields: the name and the size. It has a method printShapelnfo, which simply prints out the value of the name and the size field of a Shape object. It also has the methods printShapeName and printShapeSize, which prints the name and the size of the object, respectively. Using inheritance, create another class Square with the same fields and methods as those of Shape class. It has two additional integer fields: length and width. The methods printShapeLength and printShapeWidth that prints the object's length and width are also included in this class. You also need to override the printshapelnfo to also print out additional fields in the subclasses. Create a class with a main method to test out your classes. *Hint: The Square class is a subclass of the Shape class. 2. Create a Class Diagram for your classes.
Step by Step Solution
There are 3 Steps involved in it
1 Sample Output 2 Anima... View full answer
Get step-by-step solutions from verified subject matter experts
