InterviewSolution
| 1. |
Explain The Private Protected Method Modifier? |
|
Answer» Using the public, private and PROTECTED keywords, you can control a variable's scope. In a similar way, JAVA lets you use these attributes with class methods as well. A private protected METHOD is only visible WITHIN its class and within subclasses of the class. The difference between a protected method and a private protected method is that a private protected method is not accessible throughout the class package. To declare method as private protected, SIMPLY precede the method header with the private protected keyword, as shown: private protected int myPrivateProtectedMethod(); Using the public, private and protected keywords, you can control a variable's scope. In a similar way, Java lets you use these attributes with class methods as well. A private protected method is only visible within its class and within subclasses of the class. The difference between a protected method and a private protected method is that a private protected method is not accessible throughout the class package. To declare method as private protected, simply precede the method header with the private protected keyword, as shown: private protected int myPrivateProtectedMethod(); |
|