Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
medium

Concatenation Logic

Mark
< Prev
Next >

A program uses the indexOf method to split a string at a delimiter and reassemble the parts.

What is printed when the following Java program is compiled and run?

public class QuestionTrace {

    public static void main(String[] args) {
        String str = "code-java";
        int idx = str.indexOf("-");
        String result = str.substring(0, idx) + str.substring(idx + 1);
        System.out.println(result);
    }
}
A

java

B

code-java

C

codejava

D

code

Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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