This is a very basic and very good question sam.
First line String s = "Codeproject" doesn't create new variable but simply looks for any literal having this value in the string pool. If compiler finds one, s is initialized with this reference.
But the second line String s = new String("Codeproject") (It should have been like this) simply creates new storage in the memory with the value "Codeproject".
so if you write first line 10 times, it will create only one variable and that reference will be stored in ten instances that you declared.
While the second line will create as many variables as you want, every time creating new space in the memory.
You can find a very good reference at
http://en.csharp-online.net/CSharp_String_Theory%E2%80%94String_intern_pool[
^]
I hope this helps and you crack the interview next time.
All the best.
I found one more very nice link for JAVA string pooling :
http://www.xyzws.com/Javafaq/what-is-string-literal-pool/3[
^]
and for .NET :
http://www.webpronews.com/blogtalk/2006/10/17/net-string-internal-pool[
^]