Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

1 Sample Output 2 Anima... blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Java Programming

Authors: Joyce Farrell

9th edition

1337397075, 978-1337397070

More Books

Students also viewed these Programming questions

Question

Find V ab in the network infigure. 2 O5A 30 a V ab

Answered: 1 week ago

Question

Explain the advantages of being a limited partner in a company.

Answered: 1 week ago