‹ Back to the paper
The code snippet given below will result in: StringBuffer x = new StringBuffer("Hello")…
The code snippet given below will result in:
StringBuffer x = new StringBuffer("Hello");
StringBuffer y = new StringBuffer("HELLO");
System.out.println(x.equalsIgnoreCase(y));- aboolean value false
- bboolean value true
- cundeclared method equalsIgnoreCase(…)
- dString literals mismatch.
Answer
Answer
AICorrect option: c
Answer: (c) undeclared method equalsIgnoreCase( ).
equalsIgnoreCase( ) is a String method, not a StringBuffer method. Since x and y are StringBuffer objects, calling x.equalsIgnoreCase(y) does not compile - it is an undefined method for that class.
From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 3.