‹ Back to the paper
Question 3
1 mark
Computer ScienceISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024)MCQArrays, Strings
Choose the correct option.
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));- (a)boolean value false
- (b)boolean value true
- (c)undeclared method equalsIgnoreCase(…)
- (d)String literals mismatch.
Answer
Answer
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.