Q 3: Different packages and access modifiers package package_02; public class ClassB { public int x = 1; int y = 2; private int z = 3; public void myMethod() { System.out.print(x);...


Q 3: Different packages and access modifiers<br>package package_02;<br>public class ClassB {<br>public int x = 1;<br>int y = 2;<br>private int z = 3;<br>public void myMethod() {<br>System.out.print(x);<br>System.out.print(y);<br>System.out.print(z);<br>}<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>cb.myMethod();<br>}<br>}<br>3.1- Which statement(s) are true? Choose all that apply.<br>a. This code prints

Extracted text: Q 3: Different packages and access modifiers package package_02; public class ClassB { public int x = 1; int y = 2; private int z = 3; public void myMethod() { System.out.print(x); System.out.print(y); System.out.print(z); } } package package_01%; import package_02.ClassB; public class ClassA { public static void main(String] args) { ClassB cb = new ClassB(); cb.myMethod(); } } 3.1- Which statement(s) are true? Choose all that apply. a. This code prints "123" to the output. b. If you remove the "public" modifier from the ClassB, the code writes "123" to the output. c. If you remove the "public" modifier from the method myMethod, the code prints "123" to the output. d. This code does not compile 3.2- What do you expect if you remove the public keyword from the ClassB (public class ClassB{..})?

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here