Prashnikaप्रश्निका
Code
About
‹ Back to the paper

Question 43

1 mark

Computer ScienceISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024)OutputArrays, Strings

What is the output of the following code?

Find the output of the following snippet: void check1( ) { String x[ ] = {"Kolkata", "Chennai"…

Find the output of the following snippet:
void check1( ) 
{     
    String x[ ] = {"Kolkata", "Chennai", "Delhi"}; 
    String y[ ] = {"Kolkata", "Chennai", "Delhi"}; 
    System.out.println(x.equals(y)); 
}

Answer

Answer

false Arrays do not override equals( ), so x.equals(y) uses the default Object.equals( ), which compares object references (memory addresses), not contents; since x and y are different array objects, it returns false even though their elements are equal.