- A public
- B private
- C protected
- D void
- Share this MCQ
Answer:
A
Share this MCQ
Justification:
- The public keyword is used to make the given method accessible from any other class in the system.
- The private keyword only allows access from within the scope of the given method. This prevents accidental or unintentional re-use.
- The protected keyword allows access to any subclasses that may extend the class that the method resides in. However, it prevents access from all other outside object calls.
- The void keyword is already explicitly stated in the code snippet, and should not be used twice. This indicates that the given method does not return a value. The void keyword is used in conjunction with the scoping keywords: private, public and protected.
Related Lesson: Best Practices
Click me to Read more Question & Answer of Module 13: ClassesShare this MCQ