CodesJava

Easy learning with example program codes

can we declare a class as protected in java?


Yes, we can declare a class as protected but these classes can be only inner or nested classes. We can’t a top-level class as protected because declaring top class as protected will mean that it is accessible to the current package as well as sub packages. Now there’s no concept of sub packages in Java.

Java interview questions on access modifiers

Please follow and like us:


Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki