Q. What is the output of the following code snippet?

Code:
String s1 = “Hello”;
System.out.println(sA)substring(1, 3));
  • (A) el
  • (B) He
  • (C) ll
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (A) el
Explanation: The substring method in Java can also take a second parameter, which specifies the end index of the substring (exclusive). In this case, sA)substring(1, 3) returns “el”.
Explanation by: Kirti
The substring method in Java can also take a second parameter, which specifies the end index of the substring (exclusive). In this case, sA)substring(1, 3) returns “el”.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
200
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Kirti
Publisher
πŸ“ˆ
87%
Success Rate