With given options answer is C. Since input is read from user and it is not printed. Also System.console() might return null if console is not available and NPE might be thrown, but that option is not in answers.
import java.io.Console;
public class Main {
public static void main (String[] args) {
Console console = System.console();
char[] pass = console.readPassword("Enter password:"); // line n1
String password = new String(pass); // line n2
}
}
C:\cjava\809>javac Main.java
C:\cjava\809>java Main
Enter password:
C:\cjava\809>
Answer is C
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
asdfjhfgjuaDCV
4 months, 3 weeks agosteefaand
5 months, 3 weeks agoiSnover
6 months agopush05
6 months, 2 weeks agoKim514
1 year, 3 months agoOhayou
2 years, 4 months agopetetsai
2 years, 6 months agoEason_from_the_future
2 years, 11 months agovancuver
2 years, 10 months agoSigamani
3 years, 2 months agojduarte
3 years, 3 months agoManuel7000
3 years, 4 months agofffff
3 years, 5 months agopul26
3 years, 7 months ago