Given:
2. class MyClass { 3. MyClass(int s) { size = s; } 4. int size; /*from w w w . j a va2 s . c om*/ 5. void spin() { System.out.print(size + " inch wheel spinning, "); } 6. } 7. public class Main { 8. public static void main(String[] args) { 9. MyClass[] wa = {new MyClass(15), new MyClass(17)}; 10. for(MyClass w: wa) 11. w.spin(); 12. } }
Which are true? (Choose all that apply.)
E and F are correct.
E is correct because, as it stands, Main accesses MyClass only through its informal API, the method and the constructor.
F is correct because MyClass is not well encapsulated, and making size private would make MyClass well encapsulated.
A is incorrect because the code is legal.
B and C are incorrect because, in general, encapsulation is mostly independent of cohesion, and Main is already treating MyClass in a loosely coupled way.
D is incorrect based on the above.