Ask Question
16 January, 15:55

Consider the following partial class definitions: public class A1 { public int x; private int y; protected int z; ... } public class A2 extends A1 { protected int a; private int b; ... } public class A3 extends A2 { private int q; ... } Which of the following is true regarding the use of instance data y of class A1?

+5
Answers (1)
  1. 16 January, 19:16
    0
    The answer to the given question is "It's only accessible in A1".

    Explanation:

    In the given class definition question there are three classes defines that are A1, A2, and A3 and all the class uses the public access modifier that means it is access able every where in the program. In class A1 we define a three-variable that is "x, y, and z" in which variable x is used public access modifier, variable y is used private access modifier, and variable z is use protected access modifier. The public access modifier is access able every wherein the program and the protected access modifier is access able in the same class and the class which inherits it. but the private access modifier can not be access able outside the class.

    That's why the answer "It's only accessible in A1" is correct.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Consider the following partial class definitions: public class A1 { public int x; private int y; protected int z; ... } public class A2 ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers