Prathyu Krishna wrote:2. totally confused what reference variables are?
A reference variable is a variable that contains a reference to an object in the memory (so, the variable holds/points to an object in the memory, or points to null).
For example, assume that you have a class called Car, we can declare a reference variable of it:
Prathyu Krishna wrote:1. Strings are immutable then why does it append "d" ?
Be careful, you are not appending "d" to your String. You are doing a concatenation, which in this case creates a new String (as Roel already explained).
Your method letters() is returning the new String created by the concatenation.
As you see, you are not appending, you are doing a String concatenation, creating a new String, which means that you are not changing the original object (since Strings are immutable).
And be careful with variables and methods names. Search about good practice when naming variables and methods (like not using the same name of a variable to a method)