String Concatenation With The Plus Operator
Which line correctly concatenates s1 and s2 with a space in between using the ‘+’ operator?
public class StringConcat {
public static void main(String[] args) {
String s1 = "AP";
String s2 = "Computer";
// Missing line: Combine s1 and s2 with one space in between using the '+' operator and assign to 'result'
System.out.println(result);
}
}
A
String result = s1 + " " + s2;
B
String result = s1.concat(" ").concat(s2);
C
String result = s1 + s2;
D
String result = s1.concat(s2);
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 2 | 3 | 0m 00s | 190 |
| #2 | y.seong2027 | 2 | 2 | 0m 33s | 167 |
| #3 | jeonsaw1723 | 2 | 2 | 0m 38s | 162 |
| #4 | sgarv2513 | 1 | 1 | 0m 00s | 100 |
| #5 | lsj08030922 | 1 | 1 | 0m 19s | 81 |
| #6 | patrickmeijer009 | 1 | 2 | 0m 17s | 73 |
| #7 | areeshaabdulrasheed | 0 | 1 | 0m 14s | -24 |
| #8 | frank.personal1111 | 0 | 1 | 0m 34s | -44 |
| #9 | richa.tuli | 1 | 1 | 3m 27s | -107 |
| #10 | psak12 | 2 | 4 | 5m 41s | -161 |
APFIVE