?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

String Concatenation in Loops

APCSA-BCZNGY

Consider the following code segment.

 String name = "Amanda";
 String next = "";
 for (int j = 1; j <= name.length(); j++)
 {
      next += "" + name.substring(name.length() - j, name.length() - j + 1);
 }
System.out.println(next);

What is printed as a result of executing the code segment?

A

Amanda

B

mand

C

manda

D

adnam

E

adnamA