Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 1: Primitive Types
Start Practice TestPractice Test
About Exam
hard Solved by 3 students

String Method Manipulation

Mark
< Prev
Next >

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

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1mavericklin12522 0m 00s 200
#2Potter1611 0m 23s 77
#3busemagngr11 0m 38s 62
#4parth.taur22701 1m 03s -73
Items per page:
10
1 – 4 of 4

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|