1
visibility

What will be the output of below program?

public class Test {
public static void main(String[] args) {
String x = “abc”;
String y = “abc”;
x.concat(y);
System.out.print(x);
}
}

  • A

    abc

  • B

    abcabc

  • C

    null

  • D

    none

The x.concat(y) will create a new string but it’s not assigned to x, so the value of x is not changed.