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

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 Expert Approved Answer
Step: 1 Unlock

1 Sample Output 2 Anima... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!