You have created two strings containing names. Thus
String fname="John";
String lname="String"
How can you go about changing these strings to take new values within the same block of code?
1)
fname="Fred";
lname="Jones";
2)
String fname=new String("Fred");
String lname=new String("Jones");
3)
StringBuffer fname=new StringBuffer(fname);
StringBuffer lname=new StringBuffer(lname);
4) None of the above
I think the answer will be first one. Since once string is created we can change its value. I have checked it in eclipse.
But I got the answer as 4 none of the above since string cant be changed once created or assigned a value.
Please clarify