What is the output for the following lines of code? 1: String str = "Welcome"; 2: 3: str.concat(" to Java!"); 4: 5: System.out.println(str);

  1. A) Strings are immutable, compilation error at line 3.

  2. B) Strings are immutable, runtime exception at line 3.

  3. C) Prints "Welcome".

  4. D) Prints "Welcome to Java!".


Correct Option: C

Find more quizzes: