Question: Define a Jara class Rectangle that has the following specifications: private instance variables: mark each ) length: of type int width of type int Methods:

Define a Jara class Rectangle that has the following specifications:
private instance variables: mark each)
length: of type int
width of type int
Methods:
No argument constructor a constructor to initialize the instantiated object with default values. (0.5 makk)
Full-parameterised constructor: a constructor to initialize the instantiated objects with parameters. (1 mark)
SerLength ( xx): acts as the set method for the attribute length. (0.25 mark)
serWidth (xxx) : acts as the set method for the attribute width. (0.25 mark)
getLength (): acts as the get method for the attribute length. (0.25 mark)
getWith (): acts as the get method for the attribute width. (0.25 mark)
area(): retums the area of the rectangle. Area=length * width .(1 mark)
Define a Jara class Test Rectangle that contains a main method and test the functionality of the aboreclass Rectangle as the following:
Ask user to enter length and width of a rectangel and use it to create an object of Rectangle (rect1) using full-parameterized constrctor: (1 mark)
Create another object Rectangle using default constrictor (rect2).(1 mark)
Change the length and width of rect 2 to 10 and 5.(1 mark)
Print the information of the two objects rect1and rect 2 in the following format: (1 mark) length: 20, width: 10, area: 200 'ength: 10, width: 5, area: 50.
 Define a Jara class Rectangle that has the following specifications: private

Step by Step Solution

There are 3 Steps involved in it

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