Multiple choice technology programming languages

How many objects are created in the below code...????

String s="abc";  
String s1=new String("def");

  1. 1 Object

  2. 2 Objects

  3. 3 Objects

  4. 4 Objects

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The statement String s = 'abc' creates one object in the String Constant Pool. String s1 = new String('def') creates two objects: one in the String Constant Pool and one in the heap. In total, three objects are created, making '3 Objects' the correct answer.