Given the code fragment:
What is the result?
A. A compilation error occurs at line n1.
B. A compilation error occurs at line n2.
C. The code reads the password without echoing characters on the console.
D. A compilation error occurs because the IOException isn’t declared to be thrown or caught?
C
Exception in thread “main” java.lang.NullPointerException !!!
because the console did not find anything to read
the answer should be C
It is because System.console is not enabled in your IDE.