Question

A Java method attempts to extract a substring. public class StringProcessor {     public String extractPart(String text, int start, int length) {         // Assume text is "HelloWorld"         // Assume start = 5, length = 6         return text.substring(start, start + length); // Potential bug here     } } If text = "HelloWorld", start = 5, and length = 6, what will be the outcome of calling extractPart(text, start, length)?

A Returns "World".
B Returns "WorldD".
C Returns "oWorld".
D Throws a StringIndexOutOfBoundsException.
E Returns null.
Practice Next

Hey! Ask a query