Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 11 12 points): This problem tests your knowledge of visibility you shoul

ID: 3909035 • Letter: P

Question

Problem 11 12 points): This problem tests your knowledge of visibility you should focus on the accessibility). Suppose that we are give about class A and B that are located in different packages as shown diagram (assume classes are in the same project): the following code in the following package pl; public class A f ? void mO package p2; public class B extends A f ? int i; public void m1(Stringl args) System.out.println(i); mO; Using your knowledge on the visibility modifiers, answer the following three subquestions. A. If the question marks are replaced by blanks (default visibility), can class B be compiled? Answer: B. If the question marks are replaced by private, can class B be compiled? Answer: C. If the question marks are replaced by protected, can class B be compiled? Answer:

Explanation / Answer

A) No (Private variables are not accessible outside class)

b) No (Default variables are not accessible outside class and of different packages)

c) YES (Can be compiled by using the inheritance)

Note: For all the cases importing the super class is must because of different packages otherwise all the cases will not be compiled .

If the above solution is helpful to you in any way please rate it Or if you have any concerns please comment it, I will help you through

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote