Which statements about executing the following program are true?
package mypkg; import java.io.*; public class Main { public static void main(String... robots) { Console c = System.console(); final String response = c.readLine("Are you human?"); System.err.print(response); } }
D.
All three statements about the program are correct.
If System.console()
is available, then the program will ask the user a question and then print the response if one is entered.
If System.console()
is not available, then the program will exit with a NullPointerException.
Finally, the user may choose not to respond to the program's request for input, resulting in the program hanging indefinitely and making the last statement true.