nerdexam
Oracle

1Z0-804 · Question #108

Given the code fragment: Assume the method printNums is passed a valid array containing data. Why is this method not producingoutput on the console?

The correct answer is D. Standard error is mapped to another destination. The code compiles fine. The code runs fine. The errorstream can be redirected. System.out.println -> Sends the output to a standard output stream. Generally monitor. System.err.println -> Sends the output to a standard error stream. Generally monitor. err is the "standard"…

Java I/O Fundamentals

Question

Given the code fragment:

Assume the method printNums is passed a valid array containing data. Why is this method not producingoutput on the console?

Options

  • AThere is a compilation error.
  • BThere is a runtime exception.
  • CThe variable number is not initialized.
  • DStandard error is mapped to another destination.

How the community answered

(37 responses)
  • A
    11% (4)
  • B
    5% (2)
  • C
    3% (1)
  • D
    81% (30)

Explanation

The code compiles fine. The code runs fine. The errorstream can be redirected. System.out.println -> Sends the output to a standard output stream. Generally monitor. System.err.println -> Sends the output to a standard error stream. Generally monitor. err is the "standard" erroroutput stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the hostenvironment or user. By convention, this output stream is used to display error messages or other informationthat should come to the immediate attention of a user even if the principal output stream, the value of thevariable out, has been redirected to a file or other destination that is typically not continuously monitored.

Topics

#System.err#standard error#I/O redirection#console output

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice