Problem Statement - array.length() and substring()
Consider the following String array and give the output
String arr[]= {“DELHI”, “CHENNAI”, “MUMBAI”, “LUCKNOW”, “JAIPUR”};
System.out.println(arr[0].length()>arr[3].length());
System.out.print(arr[4].substring(0,3));
Solution
TC++ #4065
The outputs will be as follows – false JAI
System.out.println(arr[0].length()>arr[3].length());
arr[0].length() would be 5 (character count in DELHI) and arr[3].length() would be 7 (Character count in LUCKNOW). Since 5 is not greater than 7 so output would be false.
System.out.print(arr[4].substring(0,3));
Here arr[4] would be JAIPUR and in this characters from index 0 up to 3 (excluding index 3) would be JAI.