String Method Manipulation
What is printed as a result of executing the following code segment?
String ex1 = "example";
String ex2 = "elpmaxe";
ex1 = ex1.substring(1, ex1.indexOf("p"));
ex2 = ex2 + ex2.substring(3, ex1.length()) + ex2.substring(3, ex2.length());
String ex3 = ex1.substring(1) + ex2.substring(ex2.indexOf("x"), ex2.length() - 2);
System.out.println(ex3);
A
ampxepm
B
The program will terminate with a StringIndexOutOfBoundsException.
C
amxepma
D
amxema
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE