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

Explanation: The substring method in Java returns a new string that is a substring of the original string, starting from a specified index. If no end index is specified, the substring extends to the end of the original string. In this case, sA)substring(1) returns “ello”.

Explanation by: Kirti
The substring method in Java returns a new string that is a substring of the original string, starting from a specified index. If no end index is specified, the substring extends to the end of the original string. In this case, sA)substring(1) returns “ello”.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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