Q:

Java String object creation

I have been reading Java String object and I had this question - 
String x="a";
String y="b";

Does it create two objects in Java?

A:

Those two lines of code will not create any objects. String literals such as "a" are put in the string pool and made available upon class loading.
If you do
String x = new String("a");
String y = new String("b");

two objects will be created in runtime.
These questions/answers should cover follow-up questions:

Questions about Java's String pool
How many Java objects are generated by this - new String("abcd")

A:

When ever a String is initialized using new operator its new object is created.
Like if you do 
String s1= new String ("string");
String s2=new String ("string");
String s3=new String ("string");
All of the three will create a separate String object in the heap. 
Whereas if all the above strings are initialized without new operator then, firstly the string will be checked in string pool for its existence. If required string exist then the new reference will start pointing to the existing string.Otherwise it will create new sting in the pool. For example:
String s1= "string";
String s2="string";
String s3="string1";
In the above example only two string will be created in string pool ("string" and "string1"). Where String s1 and s2 will refer to single object "string" and s3 will refer to another string object "string1".

