English

What will be the output of the following program snippet? s1 = "COMPUTER"s2 = "computer" System.out.println(s1.equals(s2)); - Computer Applications

Advertisements
Advertisements

Question

What will be the output of the following program snippet? 

s1 = "COMPUTER"
s2 = "computer" 
System.out.println(s1.equals(s2)); 

Options

  • True

  • False

  • 0

  • 1

MCQ

Solution

False

Explanation:

The equals() function in Java (and other comparable languages) compares two strings exactly, including case. Because "COMPUTER" (uppercase) and "computer" (lowercase) are not the same when case-sensitive comparison is used, s1.equals(s2) gives False.

shaalaa.com
  Is there an error in this question or solution?
Chapter 4: String Handling - EXERCISES [Page 286]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 4 String Handling
EXERCISES | Q I. 6. | Page 286
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×