Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 7 students

String Reference Equality in an ArrayList

< Prev
Next >

What is the output of the following code segment?

import java.util.ArrayList;
public class Test {
    public static void main(String[] args) {
         ArrayList<String> list = new ArrayList<>();
         list.add("Hello");
         list.add(new String("Hello"));
         System.out.println(list.get(0) == list.get(1));
    }
}
A

Compilation Error

B

false

C

Runtime Error

D

true

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1kwsmith22 0m 00s 200
#2kaisuki11 0m 00s 100
#3singh.advik1313 1m 29s -9
#4psak1201 0m 58s -68
#5singhris00014 2m 24s -74
#6geethasailaja13 2m 44s -84
#7y.seong202713 3m 17s -117
#8bommasam00011 4m 40s -180
Items per page:
10
1 – 8 of 8
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|FAQ