AP CSA Unit 1 Day 4: String vs. Equals With New String

Unit 1, Section 1.11 • Cycle 2
Day 4 Advanced Practice • Harder Difficulty
Focus: Reference vs value Hard Predict Output

Advanced Practice Question

Consider the following code:
String s1 = "test";
String s2 = new String("test");
System.out.println(s1 == s2);
System.out.println(s1.equals(s2));
What is printed?
Difficulty: Hard | Topic: String == vs .equals() with new String | Cycle: 2 (Advanced)
Why This Answer?

This question tests your understanding of reference vs value. The correct answer demonstrates precise knowledge of how Java handles string == vs .equals() with new string.

Common Mistakes
Mistake #1: Misunderstanding the concept

Students often make errors with string == vs .equals() with new string by not carefully tracing execution or understanding the underlying concept.

Mistake #2: Not considering edge cases

This Cycle 2 HARD question requires careful attention to detail and understanding of how Java behaves in this scenario.

AP Exam Strategy

For questions testing string == vs .equals() with new string, always trace execution step-by-step. Write down intermediate values. Don't skip steps - the AP exam rewards precise understanding of Java behavior.

Master This Topic

This Cycle 2 HARD question tests string == vs .equals() with new string. Review Unit 1 concepts to build mastery of primitive types, objects, and String manipulation.

  • Understanding reference vs value
  • Tracing code execution accurately
  • Avoiding common pitfalls
View Unit 1 Study Guide

Ready for More Challenges?

Cycle 2 questions prepare you for the hardest AP CSA exam questions.

Study Games Practice FRQs
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.