Courseiva
Java I/O API and Securing ApplicationsmediumMultiple ChoiceObjective-mapped

1Z0-829 Java I/O API and Securing Applications Practice Question

A Java application running in a secure environment needs to read a file located outside the application's directory. Which approach correctly handles security?

⚠ Common exam trap

A common mix-up: candidates confuse OS-level file permissions (like `setReadable`) with Java's SecurityManager permissions, or assume that using a URL protocol bypasses security checks, when in fact the SecurityManager enforces the same policy regardless of the I/O API used.

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

Grant java.io.FilePermission in the security policy file for the specific file path

In a secure Java environment, the SecurityManager enforces access controls based on the security policy file. To read a file outside the application's directory, you must explicitly grant `java.io.FilePermission` with the specific file path and the `read` action in the policy file. Without this permission, any attempt to read the file will throw a `java.security.AccessControlException`.

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 FileInputStream without any additional configuration

    Why it's wrong here

    If a security manager is enabled, it may deny access without explicit permission.

  • Grant java.io.FilePermission in the security policy file for the specific file path

    Why this is correct

    This grants the application permission to read the file under the security manager.

  • Use java.net.URL to access the file via file:// protocol

    Why it's wrong here

    URL still requires permission and may not bypass security restrictions.

  • Set the file readable flag using File.setReadable(true)

    Why it's wrong here

    This changes file system permissions, not Java security policy.

About these practice questions

This 1Z0-829 question is part of Courseiva's 513-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.