Substring Extraction Logic
A student attempts to extract specific segments from a course identifier string using substring indices. Determine the final concatenation of the two segments.
What is printed when the following Java program is compiled and run?
public class QuestionTrace {
public static void main(String[] args) {
String id = "APCS-2027";
String part1 = id.substring(5, 9);
String part2 = id.substring(0, 4);
System.out.println(part1 + part2);
}
}
A
2027APCS-
B
APCS2027
C
2027APCS
D
2027-APCS
Question Leaderboard
Not enough data yet to show leaderboard.
