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?

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
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
Get step-by-step solutions from verified subject matter experts
