AP CSA Unit 3 Day 18: Private vs. Public

Unit 3, Classes & Objects • Cycle 2
Day 18 Advanced Practice • Harder Difficulty
Focus: Private vs Public Hard Private vs Public

Advanced Practice Question

Format: Private vs Public

What happens when you compile this code?
public class Secret {
    private int value = 10;
}

// In another class:
Secret s = new Secret();
System.out.println(s.value);
Difficulty: Hard  |  Topic: Private vs Public  |  Cycle: 2 (Advanced)
Why This Answer?

Private variables cannot be accessed from outside the class. This causes a compilation error.

Common Mistake
Watch Out!

Thinking private just means 'don't modify it' rather than 'can't access it'.

AP Exam Strategy

Private = completely inaccessible from outside. Must use public accessors.

Master This Topic

This Cycle 2 HARD question tests private vs public. Review Unit 3 concepts to build mastery of classes & objects.

  • Understanding private vs public
  • Tracing code execution accurately
  • Avoiding common pitfalls
View Unit 3 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.