Imagine there is a login form in Java application. We need assign usename and password to variables. Moment after we can Hash or HMAC password and keep it just for authentication step (no caching). But still we need to assign variable for Raw password.
Q1) What sort of variable type we should use to store Raw password(String, Char array or else)?
Q2) What should we do variable of Raw password after using (i.e. Just allow garbage collector to dump it after function go out of scope)?
Q3) Anything else?
This is a Java related question. I posted it here since it very much close to security.
For the C/C++ I have little idea. They are
Store password in low system level variable which not depends on other libraries. I.e. store password in char  which is very native than QString (Qt) type variables provided by frameworks.
Immediately overwrite password char after use it. Then destroy it.
Reduce the time of password in memory as low.