Question: Can somone explain why I can see C2 from C3 in P2? and why I can access o.x and invoke o.m1 from p2 in C3?Why

Can somone explain why I can see C2 from C3 in P2? and why I can access o.x and invoke o.m1 from p2 in C3?Why in class C3 and C2 there'r some variables and methods that are accessible and the ones that are not accessible.

 Can somone explain why I can see C2 from C3 inP2? and why I can access o.x and invoke o.m1 from p2

package p1; public class C1{ pub7ic int x; int y; private int z; public void ml(){ \} void m2() \{ \} private void m3() \{ \} \} package p2; public class C3 \{ void aMethod() \{ C1 0 = new C1(); can access o.x; cannot access o.y; cannot access o.z; can invoke o.m1(); cannot invoke o.m2(); cannot invoke o.m3(); \} \} \begin{tabular}{|l} package p1; \\ c1ass C1 \{ \\ \} \\ \hline \\ \hline \end{tabular} package p1; pub1ic c1ass C2 \{ can access C1 package p2; pub7ic c7ass C3 \{ cannot access C1; can access C2; \}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!