?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Last Four Digits of Phone Number String

APCSA-VVVYAE

Which of the following statements will print out the last four characters of a string named phoneNum? Assume that phoneNum is at least four characters long.

A
System.out.println(phoneNum.substring(6));
B
System.out.println(phoneNum.substring(phoneNum.length()-4, phoneNum.length()-1));
C
System.out.println(phoneNum.substring(phoneNum.length()-3));
D
System.out.println(phoneNum.substring(phoneNum.length()-4));
E
System.out.println(phoneNum.substring(3));