1.

Write statements to show how finding the length of a character array char [ ] differs from finding the length of a String object str.

Answer»

For finding length of character array char [ ] we use, a.length 

Ex: char [ ] a = {‘a’, ‘b’}; 

r = a.length; 

output: 2

For finding length of string object str, we use, str.length ( ); 

Ex : String str = “My”; int k = str.length ( ); 

output: 2



Discussion

No Comment Found

Related InterviewSolutions