Given:
04. import java.io.*;
05.
06. public class Talk {
07. public static void main(String[] args) {
08. Console c = new Console();
09. String pw;
10. System.out.print(“password: “);
11. pw = c.readLine();
12. System.out.println(“got ” + pw);
13. }
14.}
If the user types the password aiko when prompted, what is the result?
A.
password:
got
B.
password:
got aiko
C.
password: aiko
got aiko
D.
An exception is thrown at runtime.
E.
Compilation fails due to an error on line 8.
Explanation:
Main.java:8: Console() has private access in java.io.Console
Console c = new Console();
^
1 errorLine 8 should be:
Console c = System.console();