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
The program will terminate with a StringIndexOutOfBoundsException.
B
amxema
C
ampxepm
D
amxepma
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | mavericklin125 | 2 | 2 | 0m 00s | 200 |
| #2 | Potter16 | 1 | 1 | 0m 23s | 77 |
| #3 | busemagngr | 1 | 1 | 0m 38s | 62 |
| #4 | parth.taur227 | 0 | 1 | 1m 03s | -73 |
Items per page:
10
1 – 4 of 4
