Multiple choice

Which of the following methods of a String class is used to compare the given string “str1” to another string “str2” by ignoring the case consideration?

  1. str1.equals(str2);

  2. str1.equalsIgnoreCase(str2)

  3. str1.equalignoreCase(str2)

  4. str1.equalsIgnorecase(str2)

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The method equlaIgnoreCase() is used to compare the given string to another string by ignoring the case consideration. Hence, to compare str1 and str2, the statement will be as follows: str1.equalsIgnorecase(str2);