Array and String Object Comparison
Develop code to compare object references using Boolean expressions and determine the result of these expressions.
What is the most likely result of executing this code segment?
String[] arr1 = {“apple”, “banana”};
String[] arr2 = {“apple”, “banana”};
String[] arr3 = arr1;
System.out.println(arr1 == arr2);
System.out.println(arr1 == arr3);
System.out.println(Arrays.equals(arr1, arr2));
System.out.println(arr1[0] == arr2[0]);
A
false
true
true
false
B
false
true
true
true
C
true
true
true
true
D
false
false
false
true
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE