📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    Complete the Java method to extract a substring from

    text starting at startIndex and having length characters. public class StringUtil {     public String extractSubstring(String text, int startIndex, int length) {         _________ // Line to complete     } }
    A return text.substring(startIndex, length); Correct Answer Incorrect Answer
    B return text.substring(startIndex, startIndex + length); Correct Answer Incorrect Answer
    C return text.substring(startIndex); Correct Answer Incorrect Answer
    D return text.subSequence(startIndex, startIndex + length); Correct Answer Incorrect Answer
    E return text.getSubstring(startIndex, length); Correct Answer Incorrect Answer

    Solution

    The correct answer is B

    Practice Next
    ask-question