What three modifications are necessary to ensure that the class is being properly encapsulated?

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?

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?

A.
Change the access modifier of the setradius () method to private

B.
Change the getArea () method public double getArea () { return area; }

C.
When the radius is set in the Circle constructor and the setRadius () method, recomputed
the area and store it into the area field

D.
Change the getRadius () method: public double getRadius () { area = Math.PI * radius *
radius; return radius; }



Leave a Reply 10

Your email address will not be published. Required fields are marked *


Ryan

Ryan

ABC
I’m no expert but I’ll go with A,B,C. Why would you set the area in a getter? In my experience a getter should only return a value. I code in C# so maybe java programmers do things differently.

obrain

obrain

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
area.
Answer: ABC

imyrta

imyrta

Answer: A, B, C

Venk Hatta

Venk Hatta

Completed 1Z0-803 exam few days ago! Scored 90% (the passing score is 63% now)!!

Had 70 questions in my actual 1Z0-803 test.

1. Most of the questions are on Giving Code … tell the result, insert CODE, choose the best option …etc.

2. Only few questions on Java: advantages of the Java exception mechanism, benefits of using ArrayList over array, valid types for switch, Java Exception classes, two-dimensional array, improve the encapsulation of a class, java class declaration … and so on.

Used valid 1Z0-803 dumps from PassLeader (http://www.passleader.com/1z0-803.html) (272q VCE and PDF), almost all questions were same as my 1Z0-803 exam, valid enough for passing until now!