Appending strings and ints
# Topic
String
# Problem
Appending strings and ints
Select all lines that print 222.
System.out.println(1 + 1 + "2" + 2);
System.out.println(2 + 2 + "2");
System.out.println("2" + 2 + 2);
System.out.println("2" + 2 + 1 + 1);
1
2
3
4
2
3
4
Select one or more options from the list
[x] 1
[ ] 2
[x] 3
[ ] 4
1
2
3
4
2
3
4
Correct.
# Hint & Explain
In this question,I learnt that integers act as integers,that is, they get added when they are in front of any character or string,but if they are present after any character,they act like strings and concatenate....😃
编辑 (opens new window)
上次更新: 2022/09/25, 10:41:23