1Z0-829 Java I/O API and Securing Applications Practice Question
Which TWO secure coding practices should be followed when developing a Java application that handles user input? (Choose two.)
⚠ Common exam trap
Oracle often tests the distinction between predictable random generators (java.util.Random) and cryptographically secure ones (SecureRandom), expecting candidates to know that session tokens require unpredictability, not just randomness.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use PreparedStatement for database queries with user input.
Using PreparedStatement with parameterized queries prevents SQL injection by separating SQL logic from user input. The database driver automatically escapes special characters in the input, ensuring that user-supplied data is treated as literal values, not executable SQL code.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Use PreparedStatement for database queries with user input.
Why this is correct
Prevents SQL injection.
- ✗
Serialize sensitive data without encryption for performance.
Why it's wrong here
Unencrypted serialization exposes data.
- ✗
Grant java.security.AllPermission to the application's codebase.
Why it's wrong here
Defeats security; grant only required permissions.
- ✓
Validate and sanitize all user input before processing.
Why this is correct
Prevents injection and malformed data.
- ✗
Use java.util.Random for generating session tokens.
Why it's wrong here
Not cryptographically strong; use SecureRandom.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-829 question from scratch — 513 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.