1.

Can a class be declared with a protected modifier.(a) True(b) FalseThis question was posed to me by my college professor while I was bunking the class.I need to ask this question from Access Control in section Classes and Methods of Java

Answer»

The CORRECT choice is (b) False

For explanation: Protected class member (method or variable) is like package-private (default visibility), except that it ALSO can be accessed from subclasses. SINCE there is no such concept as ‘SUBPACKAGE’ or ‘package-inheritance’ in Java, declaring class protected or package-private would be the same thing.



Discussion

No Comment Found

Related InterviewSolutions