Multiple choice general knowledge science & technology

What is the output of following code: String s1 = new String("java"); String s2 = s1.replace('a','i'); s1.concat("Fundamentals"); System.out.println(s1); System.out.println((s1+s2).charAt(5));

  1. javaFundamentals u

  2. jivi i

  3. java i

  4. jiviFundamentals u

  5. compile-time error

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

Strings are immutable in Java. s1 remains "java" (concat returns new string, not assigned). s2 = "jivi". s1+s2 = "javajivi", charAt(5) = 'i' (0-indexed: j=0, a=1, v=2, a=3, j=4, i=5). Output: "java i"