Computer Applications
What will be the output of the following program snippet?
s1 = "COMPUTER";
s2 = "computer";
System.out.println(s1.equals(s2));
- True
- False
- 0
- 1
Java String Handling
24 Likes
Answer
False
Reason — equals() method treats uppercase and lowercase characters differently. So, the two strings will not be considered equal and the boolean value 'false' will be returned.
Answered By
13 Likes
Related Questions
What will be the value stored in the variable 'c' if the following statement is executed?
c = "COMPUTER".charAt("COMPUTER ".indexOf('P'))- 3
- 4
- P
- M
Which of the following functions is used to remove leading and trailing white spaces from the string?
- trim( )
- trail( )
- truncate( )
- slice( )
What will be the output of the following program snippet?
str1 = "AMAN";
str2 = "AMIT";
System.out.println(str1.compareTo(str2));- 8
- 0
- -8
- 2
Which of the following packages contain string functions?
- java.awt
- java.string
- java.math
- java.lang