Computer Applications
Write the output for the following:
String s1 = "phoenix"; String s2 ="island";
System.out.println(s1.substring(0).concat(s2.substring(2)));
System.out.println(s2.toUpperCase());
Java
Java String Handling
ICSE 2019
35 Likes
Answer
The output of above code is:
phoenixland
ISLAND
Working
s1.substring(0) results in phoenix. s2.substring(2) results in land. concat method joins both of them resulting in phoenixland. s2.toUpperCase() converts island to uppercase.
Answered By
17 Likes
Related Questions
Define a class to accept a string and convert the same to uppercase, create and display the new string by replacing each vowel by immediate next character and every consonant by the previous character. The other characters remain the same.
Example:
Input : #IMAGINATION@2024
Output : #JLBFJMBSJPM@2024Write 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));
The output of the statement "CONCENTRATION".indexOf('T') is:
- 9
- 7
- 6
- (-1)