Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 16 students

String Concatenation With The Plus Operator

< Prev
Next >

In the code segment below, which statement correctly concatenates the String variables s1 and s2 with a space between them? The statement must use the + operator for concatenation and assign the result to a new String variable named result.

public class StringConcat {
    public static void main(String[] args) {
        String s1 = "AP";
        String s2 = "Computer";
        // Missing statement
        System.out.println(result);
    }
}
A

String result = s1 + " " + s2;

B

String result = s1.concat(s2);

C

String result = s1 + s2;

D

String result = s1.concat(" ").concat(s2);

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1kaisuki23 0m 00s 190
#2y.seong202722 0m 33s 167
#3jeonsaw172322 0m 38s 162
#4sgarv251311 0m 00s 100
#5lsj0803092211 0m 19s 81
#6patrickmeijer00912 0m 17s 73
#7ananyetyagi11 0m 29s 71
#8chunxiangxu.cxu23 2m 17s 53
#9varunrajaram111 1m 00s 40
#10areeshaabdulrasheed01 0m 14s -24
Items per page:
10
1 – 10 of 15
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|FAQ