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
Write a program in Java to enter any sentence. Also ask the user to enter a word. Print the number of times the word entered is present in the sentence. If the word is not present in the sentence, then print an appropriate message.
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.
Which of the following returns a String?
- length()
- charAt(int)
- replace(char, char)
- indexOf(String)