🎴 Flashcard Mode
Java Basics (GATE - CS)
Card1 / 15
Mastered0
Review0
QuestionClick to flip
String s = “Welcome To Java” s.substring(4, 3 );
What will be the result of the above code?
AnswerClick to flip back
A
Runtime error
💡 Explanation:
This is the correct answer. Substring method takes two parameters (beginIndex,EndIndex). Substring( int Begin , int End). It returns the string from begin to end -1. But if the begin index is greater than the end index then a runtime error will occur. So here substring(4,3) will give a runtime error.