Nissi Hari

Greenhorn
+ Follow
since Oct 31, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Nissi Hari

Hi Rajani,
I think u r wrong and Viji's reply is correct.
Lets see how it happens
String s1,s2,s3,s4;
s1 = "Hello"; ===> "Hello" created in String pool
s2 = s1; **** The previous "Hello" is used here
s3 = s2 + "Pal";===>"Pal" created in String pool then "HelloPal"
is created
s4 = s3; **** The previous "HelloPal" is used here
Hope this is clear.
Nissi

Just Remember that casting of references is fine if it goes upwards in the inheritance tree . Suppose u create a sub object(using new), which is the subclass and cast it to a Base object it is fine.Because in this case you are going up the in inheritance hierarchy.