Ask Question
27 October, 11:26

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?

+3
Answers (1)
  1. 27 October, 11:54
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers