Note: ClassA and ClassB in this question are in two different packages, while in the previous question, they were in the same package. package package_02; public class ClassB { public int x = 1; int y...


Note: ClassA and ClassB in this question are in two<br>different packages, while in the previous question, they<br>were in the same package.<br>package package_02;<br>public class ClassB {<br>public int x = 1;<br>int y = 2;<br>private int z =3;<br>}<br>package package_01;<br>import package_02.ClassB;<br>public class ClassA {<br>public static void main(String[] args) {<br>ClassB cb = new ClassB();<br>// System.out.print(cb.x); /* 1 */<br>// System.out.print(cb.y); /* 2 */<br>// System.out.print(cb.z); /* 3 */<br>}<br>}<br>2.1- Which statement(s) are true? Choose all that<br>apply.<br>a. If statement 1 is uncommented, the code prints

Extracted text: Note: ClassA and ClassB in this question are in two different packages, while in the previous question, they were in the same package. package package_02; public class ClassB { public int x = 1; int y = 2; private int z =3; } package package_01; import package_02.ClassB; public class ClassA { public static void main(String[] args) { ClassB cb = new ClassB(); // System.out.print(cb.x); /* 1 */ // System.out.print(cb.y); /* 2 */ // System.out.print(cb.z); /* 3 */ } } 2.1- Which statement(s) are true? Choose all that apply. a. If statement 1 is uncommented, the code prints "1" to the output. b. If statement 2 is uncommented, the code prints "2" to the output. c. If statement 3 is uncommented, the code prints "3" to the output. This ode does not compile. 2.2- Try to do the following: Declare an integer variable called myInt in the ClassB; the variable myInt should be accessible through the object cb. Write a statement in ClassA to check out the accessibility of your variable.

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here