LearnFrenzy
Sign in Take a free test

Encapsulation · Encapsulation MCQ · Question 12

What a class invariant is Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 12 Back to Exercise

What is a class invariant?

  • A A final variable
  • B A condition that must be true for every object after construction and after every public method Correct
  • C A static field
  • D An unchanging method name
Correct Answer: Option B

Example: balance ≥ 0, or min ≤ max.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links