Describe the effect of the following Java statements You are
Solution
String name;
name = new String(\"Java Programming\"); //An instance of String object is created, and the value Java Programming is stored in it, and is assigned to the String variable name.
name = new String(\"Java Programming\"); //Another instance of String object is created, and the value Java Programming is stored in it, and is re-assigned to the String variable name.
name = new String(\"Java Programming\"); //One more instance of String object is created, and the value Java Programming is stored in it, and is re-assigned to the String variable name.
Ofcourse, the last 2 statements are redundant to the human eye, but actually, 3 instances will be created by the Java interpreter, but only the last instance is accessible by the variable name.
