How to implement encapsulation in a Java class?
<p>I am learning Java and have been given these options:</p>

<p>How can you implement encapsulation in a class?</p>

<ol>
<li>Make all variables protected and only allow access via methods.</li>
<li>Make all variables private and only allow access via methods.</li>
<li>Ensure all variables are represented by wrapper classes.</li>
<li>Ensure all variables are accessed through methods in an ancestor class.</li>
</ol>

<p>My choice is the second but I also would like to find out if anyone considers any other choice is correct? Also are there any other ways to implement encapsulation that are not covered here?</p>
