nerdexam
Oracle

1Z0-803 · Question #67

Given: This class is poorly encapsulated. You need to change the circle class to compute and return the area instead. What three modifications are necessary to ensure that the class is being properly

The correct answer is A. Change the access modifier of the setradius () method to private B. Change the getArea () method C. When the radius is set in the Circle constructor and the setRadius () method, recomputed the area. A: There is no need to have SetRadius as public as the radius can be set through the Circle method. B: We need to return the area in the GetArea method. C: When the radius changes the Area must change as well. Incorrect answer: D: the GetRadius() method does not change the radius

Working with Methods and Encapsulation

Question

Given:

This class is poorly encapsulated. You need to change the circle class to compute and return the area instead. What three modifications are necessary to ensure that the class is being properly encapsulated?

Exhibit

1Z0-803 question #67 exhibit

Options

  • AChange the access modifier of the setradius () method to private
  • BChange the getArea () method
  • CWhen the radius is set in the Circle constructor and the setRadius () method, recomputed the area
  • DChange the getRadius () method:

How the community answered

(23 responses)
  • A
    57% (13)
  • D
    43% (10)

Explanation

A: There is no need to have SetRadius as public as the radius can be set through the Circle method. B: We need to return the area in the GetArea method. C: When the radius changes the Area must change as well. Incorrect answer: D: the GetRadius() method does not change the radius, so there is no need to recomputed the

Topics

#encapsulation#access modifiers#object-oriented design

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice