Computer Applications
What will be the output for the following program segment?
String s = new String ("abc");
System.out.println(s.toUpperCase( ));
Java
Java String Handling
6 Likes
Answer
ABC
Working
String s
stores "abc".
toUpperCase( ) method converts all of the characters in the String to upper case. Thus, "abc" is converted to "ABC" and printed on the output screen.
Answered By
3 Likes
Related Questions
What will be the output of the following code snippet when combined with suitable declarations and run?
StringBuffer city = new StringBuffer("Madras"); StringBuffer string = new StringBuffer( ); string.append(new String(city)); string.insert(0, "Central "); String.out.println(string);
State the method that:
(i) converts a string to a primitive float data type.
(ii) determines if the specified character is an uppercase character.
Write a program to do the following :
(a) To output the question "Who is the inventor of Java" ?
(b) To accept an answer.
(c) To print out "Good" and then stop, if the answer is correct.
(d) To output the message "try again", if the answer is wrong.
(e) To display the correct answer when the answer is wrong even at the third attempt and stop.
Give the output of the following program :
class MainString { public static void main(String[ ] args) { StringBuffer s = new StringBuffer("String"); if((s.length( ) > 5) && (s.append("Buffer").equals("X"))) ; // empty statement System.out.println(s); } }