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
36 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
18 Likes
Related Questions
Write a Java program to enter any sentence and convert the sentence to uppercase. Print only those words of the sentence whose first and last letters are the same.
The output of the statement "CONCENTRATION".indexOf('T') is:
- 9
- 7
- 6
- (-1)
Which of the following returns a String?
- length()
- charAt(int)
- replace(char, char)
- indexOf(String)
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@2024