protected_Keyword 悠悠 2021-11-04 13:54 308阅读 0赞 ## protected Java Keyword with Examples ## The protected keyword is an access control modifier that may be applied to a class, a method or a field (a variable declared in a class). If a class or its members are declared as protected are only accessible by the classes of the same package and the subclasses present in any package. You can also say that the protected access modifier is similar to default access modifier with one exception that it has visibility in subclasses. Classes cannot be declared protected. This access modifier is generally used in a parent-child relationship. protected Java Keyword Example Below diagram demonstrates the example of protected access modifier and it’s visibility:
还没有评论,来说两句吧...