In Java, why shouldn't you use strings to store a password?
While this may seem like a rudimentary question regarding your knowledge of Java, your interviewer is looking to ideally hear that you understand the principle differences between string and character arrays. Asking about the storage of passwords within a system gives you the opportunity here to point out the differences between the two. In the end, while explaining the differences, be sure to tie it back to the original question on why strings shouldn't be used to store passwords.
"To store a password, character array is the obvious best choice because character arrays are mutable. If a string was utilized to store passwords, a definite security risk would be present to anyone that would have access to the memory dump from the system."
