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



Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap