Determine output:
public class Test{
public static void main(String args[]){
String s1 = "SITHA";
String s2 = "RAMA";
System.out.println(s1.charAt(0) > s2.charAt(0));
}
}
public class Test{
public static void main(String args[]){
String s1 = "SITHA";
String s2 = "RAMA";
System.out.println(s1.charAt(0) > s2.charAt(0));
}
}
A. true
B. false
C. 0
D. Compilation error
E. Throws Exception
Answer: Option A
Solution(By Examveda Team)
Output will be True. Since when s1.charAt(0) ascii value is greater then s2.charAt(0). So it will return True.Join The Discussion
Comments ( 5 )
Related Questions on Strings
In Java, which class is used to represent a sequence of characters as a string?
A. String
B. StringBuilder
C. StringSequence
D. StringArray
What is the correct way to create a new empty String object in Java?
A. String emptyString = "";
B. String emptyString = new String();
C. String emptyString = " ";
D. String emptyString = null;
E. Both A and B
Which of the following methods is used to compare two strings for equality in Java?
A. equals()
B. compareTo()
C. equalsIgnoreCase()
D. compare()
s1.charAt(0) > s2.charAt(0) is same as 'S' > 'R'
Ascii of S=83
Ascii of R=82
so 83 > 82
true
how is it possible can you please explain this answer
If we run it it shows compilation error.
How it becomes true can any one explains it.....
what will be the output?