Monday, August 16, 2010

Console: Bob.java

Courtesy of Sun Web Learning Center



12.    char[] pw = c.readPassword("%s", "pw: ");
13.    for(char ch : pw)
14.      System.out.print(ch);

And when prompted the user keys "bob" What is displayed on the terminal?

A

pw:

B

pw:

bob

C

pw: bob

bob

D

An exception is thrown


B is correct. By default the readPassword() method does not echo the user's input.

No comments:

Post a Comment