1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ivenika [448]
3 years ago
10

Write your own accessor and mutator method for the Rectangle class instance variables. You should create the following methods:

getHeight setHeight getWidth setWidth getArea getPerimeter toString- The output of a rectangle with width 10 and height 4 method should be:
Computers and Technology
1 answer:
frozen [14]3 years ago
7 0

Answer:

Public int getHeight(){

return height;

}

public int getWidht(){

return widht;

}

public int setHeight(int change){

height = change;

}

public int setWidht(int change){

widht = change;

}

public int getPerimeter(){

int perimeter = 2 ( getWidht() + getHeight ());

return perimeter;

If the width is 10 and height 4, the perimeter should be 28.

Explanation:

An accessor in Java is a method that is used to get the value of an object variable. The program above has three accessor methods, getHeight, getWidht and getPerimeter.

Mutators are methods that is used to change of mutate the value of object variables. They are denoted or identified by the set prefix in their names. From the class code, the mutator are setHeight and setWidht.

You might be interested in
PLEASE IM IN AN EXAM I NEED HELP ASAPPP<br> (Appshed question)
Anika [276]
Home Screen with pop up so it’s the first one
6 0
3 years ago
Read 2 more answers
Why is Internet fraud becoming increasingly common?
Nikitich [7]
The internet has billions of users, and is gaining more everyday. As people gain more and more technological resources, it becomes easier for them to steal people’s information.
7 0
3 years ago
Is October tornado season?
Reptile [31]
No October is not tornado season
5 0
3 years ago
Read 2 more answers
Which of the following best describes a situation where software should be upgraded instead of replaced? A three-year-old laptop
Karo-lina-s [1.5K]
The six month old computer that needs more RAM is the answer. it is the only one using software.
6 0
4 years ago
PLEASE HELP! WILL MARK AS BRAINLIEST!
insens350 [35]

Answer:

JavaScript can be implemented using JavaScript statements that are placed within the HTML tag

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Stan is looking at cloud computing options for his business needs. He wants a model that helps his business customers and client
    12·2 answers
  • Printed versions of your presentation that contain the slides and blank lines below are called speakers notes
    11·2 answers
  • The guy wire BD exerts on the telephone pole AC a force P directed along BD. Knowing that P must have a 720-N component perpendi
    10·1 answer
  • Technician A says that automotive engine blocks are usually classified by the number of cylinders the block. Technician B says t
    9·1 answer
  • Consider the problem of finding the distance between the two closest numbers in an array of n numbers. (The distance between two
    13·1 answer
  • If the force of gravity _ then the weight of an object will _
    8·2 answers
  • Disk ___________________ helps improve the speed and efficiency of a hard disk.
    6·1 answer
  • Come up with a system, using only
    8·1 answer
  • An employee is working on building a new computer application for a friend. For this purpose, he uses the software that is regis
    5·1 answer
  • you have just finished developing a new application. before putting it on the website for users to download, you want to provide
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!