Ask Question
19 March, 10:25

What modifier should you use on a class so that a class in the same package can access it but a class (including a subclass) in a different package cannot access it? A. publicB. privateC. protectedD. Use the default modifier.

+2
Answers (1)
  1. 19 March, 13:55
    0
    Option (B) is the correct answer of this question.

    Explanation:

    In the Private access modifier we can access the property and field within the package or class we cannot accessing the member outside the class.

    We use private keyword for declaring the private access modifier. In the public access modifier we accessing the property outside the class so it's a incorrect option. In the protected access modifier we access the property of class package and subpackage both so it's a incorrect option. The default modifier is incorrect it not follow the given scenario so it's incorrect.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “What modifier should you use on a class so that a class in the same package can access it but a class (including a subclass) in a different ...” 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