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

Substring Extraction

Mark
< Prev
Next >

A program manipulates a String representing a date-like code to extract specific segments.

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

public class QuestionTrace {

    public static void main(String[] args) {
        String s = "APCS-2027";
        String res = s.substring(1, 4) + s.substring(5);
        System.out.println(res);
    }
}
A

APCS2027

B

PCS27

C

PCS-2027

D

PCS2027

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|