Computer Applications
Write the output for the following:
String s1 = "Life is Beautiful";
System.out.println("Earth" + s1.substring(4));
System.out.println(s1.endsWith("L"));
Java
Java String Handling
37 Likes
Answer
Earth is Beautiful
false
Working
s1.substring(4)
will return a substring starting at index 4 of s1 till its end so its output will be " is Beautiful". System.out.println("Earth" + s1.substring(4))
will concatenate "Earth" and " is Beautiful" to given the output as "Earth is Beautiful".
As the last character of s1 is a small l not a capital L so s1.endsWith("L")
returns false.
Answered By
17 Likes
Related Questions
The output of the statement "CONCENTRATION".indexOf('T') is:
- 9
- 7
- 6
- (-1)
The output of a program which extracts a part of the string "SUBMISSION" is as follows:
(a) "MISS"
(b) "MISSION"If
String str = "SUBMISSION";
write appropriate Java statements to get the above outputs.The output of the statement "talent".compareTo("genius") is:
- 11
- –11
- 0
- 13
Write the output of the following String methods:
String x= "Galaxy", y= "Games";
(a) System.out.println(x.charAt(0)==y.charAt(0));
(b) System.out.println(x.compareTo(y));