Q. Which method of the String class would you use to get the number of characters in a string?

A
size()
B
length()
C
capacity()
D
count()
Solution:

The length() method returns the number of characters in the string. size() is used for collections like ArrayList, and length is a property for arrays.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!