InterviewSolution
| 1. |
What Is The Private 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 method is only visible within its class. Subclasses cannot access private methods. To declare a method as private, simply precede the method header with the private keyword, as shown: private INT myPrivateMethod(); 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 method is only visible within its class. Subclasses cannot access private methods. To declare a method as private, simply precede the method header with the private keyword, as shown: private int myPrivateMethod(); |
|