QUIZ - journaldev Flashcards

1
Q

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. abcabc
B. abc
C. null

A

Correct Answer: B

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly