Oracle
1Z0-829 · Question #31
1Z0-829 Question #31: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-829 to reveal the answer and full explanation for question #31. The question stem and answer options stay visible for context.
Using Java I/O API
Question
Which code line n1, obtains the java.io.Console object?
Options
- A// Line n1 String input = console.readLine("Input a number: "); int number = Integer.parseInt(input); if (number % 2 == 0) { System.out.println(number + " is even."); } else { System.out.println(number + " is odd"); }
- BConsole console = System.console();
- CConsole console = Console.getInstance();
- DConsole console = new Console(System.in);
- EConsole console = new Console(new InputStreamReader(System.in));
Unlock 1Z0-829 to see the answer
You've previewed enough free 1Z0-829 questions. Unlock 1Z0-829 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.
Topics
#Console I/O#System.console()#Java I/O API#obtaining streams