Examveda
Examveda

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));
        }
}

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.

This Question Belongs to Java Program >> Strings

Join The Discussion

Comments ( 5 )

  1. Ajeet Kumar
    Ajeet Kumar :
    6 years ago

    s1.charAt(0) > s2.charAt(0) is same as 'S' > 'R'
    Ascii of S=83
    Ascii of R=82
    so 83 > 82
    true

  2. Tamil Selvi
    Tamil Selvi :
    7 years ago

    how is it possible can you please explain this answer

  3. Aditya Malik
    Aditya Malik :
    7 years ago

    If we run it it shows compilation error.

  4. Dhanasri Dhana
    Dhanasri Dhana :
    7 years ago

    How it becomes true can any one explains it.....

  5. Akshit Minocha
    Akshit Minocha :
    7 years ago

    what will be the output?

Related Questions on Strings