102k views
3 votes
What type of return does the length ( ) method return?

A) double
B) string
C) char
D) int

1 Answer

7 votes

Final answer:

The length() method returns an int which is the number of characters in a string.

Step-by-step explanation:

The length() method, commonly used in programming to get the number of characters in a string, returns an int. This means that when you use the length() method on a string, it will return an integer value that represents how many characters are in that string. For instance, if you have a string variable String myString = "Hello"; and you call myString.length();, it would return 5 because there are five characters in the word "Hello".

User KP Taylor
by
8.6k points