Explanation : Strings are immutable. So str.concat("to Java!") will not append anything to str. Infact it will create another string "Welcome to Java!" and leaves it.