Java SE 11 Developer — Question 34
Which two safely validate inputs? (Choose two.)
Answer options
- A. Delegate numeric range checking of values to the database.
- B. Accept only valid characters and input values.
- C. Use trusted domain-specific libraries to validate inputs.
- D. Assume inputs have already been validated.
- E. Modify the input values, as needed, to pass validation.
Correct answer: A, B
Explanation
Option A is correct because delegating numeric range checks to the database ensures that validation occurs at a secure level. Option B is also correct as restricting input to valid characters helps prevent injection attacks. Options C, D, and E are incorrect; C relies on external libraries which may not be trustworthy, D is dangerous as it assumes validation has occurred, and E is misleading as modifying inputs can introduce vulnerabilities.