Java OCA OCP Practice Question 49

Question

What is the output of the following program?

public class Main {
   public static void main(String args[]) {
      String s1 = "abc";
      String s2 = "def";
      String s3 = s1.concat(s2.toUpperCase());
      System.out.println(s1 + s2 + s3);
   }
}
  • A. abcdefabcdef
  • B. abcabcDEFDEF
  • C. abcdefabcDEF
  • D. None of the above


C.

Note

String objects are immutable and cannot be changed.




PreviousNext

Related