Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q7 of 15
Java - Strings and String Handling
Find the error in this code snippet:
String s = "Example";
if(s.equalsIgnoreCase = "example") {
  System.out.println("Match");
}
AequalsIgnoreCase is not a method
BAssignment operator used instead of method call
CMissing semicolon after if condition
DString comparison should use == operator
Step-by-Step Solution
Solution:
  1. Step 1: Analyze equalsIgnoreCase usage

    equalsIgnoreCase is a method and must be called with parentheses.
  2. Step 2: Identify operator mistake

    Code uses '=' (assignment) instead of '()' method call.
  3. Final Answer:

    Assignment operator used instead of method call -> Option B
  4. Quick Check:

    Use equalsIgnoreCase() with parentheses, not '=' [OK]
Quick Trick: Call equalsIgnoreCase() with parentheses [OK]
Common Mistakes:
  • Using '=' instead of method call
  • Using == for string comparison

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes