Multiple choice technology web technology

What is the output (Assuming written inside main) String s1 = new String("amit"); String s2 = s1.replace('m','i'); s1.concat("Poddar"); System.out.println(s1); System.out.println((s1+s2).charAt(5));

  1. Compile error

  2. amitPoddar O

  3. amitPoddar I

  4. amit I

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

s1 remains 'amit' because Strings are immutable and s1.concat is ignored. s2 becomes 'aiit'. s1+s2 is 'amitaiit'. The character at index 5 of 'amitaiit' (0-indexed: a=0, m=1, i=2, t=3, a=4, i=5) is 'i'. Thus, printing s1 gives 'amit', and the char is 'I' (capitalized in options).