?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Substring and IndexOf Methods

APCSA-4UMZWD

Consider the following string.

String name = "Amanda";

What does sub contain after the following code is executed?

String sub = name.substring(name.indexOf('m'), name.indexOf(name.substring(name.length()-1)));
A

sub = "manda"

B

sub = "ma"

C

compilation error

D

sub = "mand"

E

sub = "m"