Home / Programming MCQs / JAVA MCQs / Question

K

Kirti • 10.37K Points
Tutor II

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

Code:
String s1 = “Hello”;
System.out.println(sA)length());
(A) 5
(B) 6
(C) Error
(D) None of these
Explanation by: Kirti
The length method in Java returns the length of a string, which is the number of characters in the string. In this case, sA)length() returns 5.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.