Bill Gates wants your help in correcting the following error. Suggest the correct solution:
Statement -System. out. Print ln (s. sub Str (1,2));
Error - cannot resolve symbol method sub Str (int, int)
-
Use sub string
-
Use one argument
-
Use sub str
-
Use two arguments
A
Correct answer
Explanation
The error occurs because Java is case-sensitive and String methods have specific names. The correct method name is 'substring()' not 'subStr()'. The space in 'sub Str' also causes compilation error. Java String objects use camelCase naming convention for methods like substring(), indexOf(), charAt().