Ask Question
5 June, 16:19

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?

+1
Answers (1)
  1. 5 June, 17:53
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers