Q 1: Access class members from the same package Note: ClassA and ClassB in this question are in the same package. public class ClassB { public int x = 1; int y = 2; private int z =3; } ملاحظة: عرف كل...


Q 1: Access class members from the same package<br>Note: ClassA and ClassB in this question are in the same package.<br>public class ClassB {<br>public int x = 1;<br>int y = 2;<br>private int z =3;<br>}<br>ملاحظة: عرف كل کلاس في ملف لانه لا يجوز آن يكون کلاسين public في نفس الملف.<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>1.1- Which statement(s) are true? Choose all that apply.<br>a. If statement 1 is uncommented, the code prints

Extracted text: Q 1: Access class members from the same package Note: ClassA and ClassB in this question are in the same package. public class ClassB { public int x = 1; int y = 2; private int z =3; } ملاحظة: عرف كل کلاس في ملف لانه لا يجوز آن يكون کلاسين public في نفس الملف. 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 */ } } 1.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. d. This code does not compile. 1.2- Try to do the following: • Declare a character type variable myChar in the class ClassB, the variable myChar shouldn't be accessible through the object cb. • Add a statement to the classA to test whether myChar is accessible.

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here