nerdexam
Oracle

1Z0-809 · Question #158

Given the following class: public class Rectangle { private double length; private double height; private double area; public void setLength(double length) { this.length = length; } public void…

The correct answer is C. Call the setArea method at the end of the setLength method. F. Call the setArea method at the end of the setHeight method. You've hit your session limit · resets 10:20pm (America/New_York)

Question

Given the following class: public class Rectangle { private double length; private double height; private double area; public void setLength(double length) { this.length = length; } public void setHeight(double height) { this.height = height; } public void setArea() { area = length*height; } } Which two changes would encapsulate this class and ensure that the area field is always equal to length * height whenever the Rectangle class is used?

Options

  • ACall the setArea method at the beginning of the setLength method.
  • BChange the area field to public.
  • CCall the setArea method at the end of the setLength method.
  • DCall the setArea method at the beginning of the setHeight method.
  • EChange the setArea method to private.
  • FCall the setArea method at the end of the setHeight method.

How the community answered

(26 responses)
  • A
    8% (2)
  • B
    15% (4)
  • C
    73% (19)
  • E
    4% (1)

Explanation

You've hit your session limit · resets 10:20pm (America/New_York)

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice