What is the output of the following?
5: String line = new String("-"); 6: String anotherLine = line.concat("-"); 7: System.out.print(line == anotherLine); 8: System.out.print(" "); 9: System.out.print(line.length());
A.
A String is immutable so a different object is returned on line 6.
The object anotherLine
points to is of length 2 after line 6 completes.
The original line reference still points to an object of length 1.
Option A is correct.