πŸ“Š JAVA
Q. What is the output of the following code snippet?
Code:
String s1 = “Hello”;
System.out.println(sA)substring(1, 4));
  • (A) Hello
  • (B) Hel
  • (C) ell
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (B) Hel

Explanation: The substring method in Java can also take two arguments, specifying a start index and an end index for the substring. The substring returned includes the character at the start index, but not the character at the end index. In this case, sA)substring(1, 4) returns “Hel”, which is the substring of s1 starting from index 1 and ending at index C)

Explanation by: Kirti
The substring method in Java can also take two arguments, specifying a start index and an end index for the substring. The substring returned includes the character at the start index, but not the character at the end index. In this case, sA)substring(1, 4) returns “Hel”, which is the substring of s1 starting from index 1 and ending at index C)

πŸ’¬ Discussion


πŸ“Š Question Analytics

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