Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a class called Rectangle with the following members: Public Class constants DEFAULT _ WIDTH with value of 5 Public Class constants DEFAULT _ HEIGHTS

Develop a class called Rectangle with the following members:
Public Class constants DEFAULT_WIDTH with value of 5
Public Class constants DEFAULT_HEIGHTS with value of 5
Public Instance Variables width, length, area
Public method initRect that takes as input a width and height and sets the corresponding member values to these valuesthe method returns nothing
Public method computeArea that computes area and saves it as the variable area
Public method getArea that returns the area of the object
Public method setWidth that sets the width of the object to the corresponding value supplied by the input parameter
Public method setLength that sets the length of the object to the corresponding value supplied by the input parameter
Provide the body of a main program that would perform the following:
Creates an object of the class Rectangle called r
Initializes the object with a value of 5 for width and the content of the variable y as length
Computes the area of r
Gets the area of the object and displays it to the user via the System.out command

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

ISBN: 1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

=+7 How has the COVID-19 pandemic impacted the operations of IHRM?

Answered: 1 week ago