Ask 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 package cannot access it? A. publicB. privateC. protectedD. Use the default modifier.

+1
Answers (1)
  1. 16 April, 07:49
    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 & 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