Question: Which changes made to the following class would help to properly encapsulate the data in the class? A. Add a getter method for material. B.

Which changes made to the following class would help to properly encapsulate the data in the class? 

package shield; public class Protect { private String material; protected int strength;

A. Add a getter method for material.

B. Add a setter method for material.

C. Change the access modifier of material to protected.

D. Change the access modifier of strength to private.

E. None of the above.

package shield; public class Protect { private String material; protected int strength; } public int getStrength () { return strength; } public void setStrength (int strength) { this.strength = strength; }

Step by Step Solution

3.39 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Encapsulation in objectoriented programming is the bundling of data with the methods that operate on that data or the restriction of direct access to ... View full answer

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 Oracle Questions!