Courseiva

1Z0-829 Practice Question: Handling Date, Time, Text, Numeric and Boolean Values

Which code correctly reads a line of text from the console using System.console()?

⚠ Common exam trap

Many candidates choose option D because `BufferedReader` is a common pattern for reading input, but they overlook that the question explicitly requires `System.console()`, not just any reader of `System.in`.

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

Console cons = System.console(); String line = cons.readLine();

`System.console()` returns a `Console` object that provides a direct, secure method for reading text from the console without buffering issues. The `readLine()` method reads a line of text as a `String`, which is the intended approach when using the console API.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Scanner sc = new Scanner(System.in); String line = sc.nextLine();

    Why it's wrong here

    Incorrect: This works but is not using Console; the question specifically asks using System.console().

  • Console cons = System.console(); String line = cons.readLine();

    Why this is correct

    Correct: Console.readLine() reads a line of input from the console.

  • DataInputStream dis = new DataInputStream(System.in); String line = dis.readLine();

    Why it's wrong here

    Incorrect: readLine() is deprecated and not recommended.

  • BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine();

    Why it's wrong here

    Incorrect: Same as B, not using Console.

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 →

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.