Substring Extraction
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
Question Leaderboard
Not enough data yet to show leaderboard.
