Substring Extraction Logic
A program processes a diagnostic code string using nested substring operations to isolate specific digits.
What is printed when the following Java program is compiled and run?
public class QuestionTrace {
public static void main(String[] args) {
String code = "ID-9876-X";
String sub = code.substring(3, 7);
String res = sub.substring(1, 3);
System.out.println(res);
}
}
A
98
B
87
C
76
D
876
Question Leaderboard
Not enough data yet to show leaderboard.
