| 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 1 students
String Method Manipulation
< 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

ampxepm

B

The program will terminate with a StringIndexOutOfBoundsException.

C

amxepma

D

amxema

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy