Given the proper import statement(s) and:
4. Console c = System.console(); 5. char[] pw; 6. if(c == null) return; 7. pw = c.readPassword("%s", "pw: "); 8. System.out.println(c.readLine("%s", "input: "));
Which statements are true? (Choose all that apply.)
readPassword()
method will echo the password the user types.Console()
;".D is correct.
The code is all legal, but it's possible to invoke a Java program in an environment that doesn't have a Console object-therefore, the if test on line 6 can sometimes be true.
The readPassword()
method Always disables echoing.
The Console object is Always constructed using System.console()
, but the Console class is in java.io.