PRASHNIKAप्रश्निका
‹ Back to the paper

The code snippet given below will result in: StringBuffer x = new StringBuffer("Hello")…

Computer Science20251 markMCQ
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

AI

Correct 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.
Arrays, Strings

From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 3.