014-007-004
Final Method: Preventing Override
Hard
Problem Description
Final method: Preventing override
In this problem, you will create a program that defines a final validate() method in the SecurityBase class, calls it from the process() method of the child class SecureService, and displays the result along with the input data name to standard output.
Learning Objective: Understand how to prevent method override using final modifier
Overview
Create a program that defines a final method in SecurityBase class and confirms it cannot be overridden in child classes.
Specifications
- SecurityBase class: final validate() method (outputs "Security Check Passed")
- SecureService class: extends SecurityBase, adds process(String data) method
- process() calls validate() then processes the input data
Input
- A single line string (data name to process)
Output Format
Security Check Passed
Processing: [input data name]
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up