LearnFrenzy
Sign in Take a free test

Records, Enums and Sealed Classes · Records, Enums and Sealed Classes MCQ · Question 19

A record pattern Answer, explanation & discussion

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

What does if (o instanceof Point(int x, int y)) do (Java 21)?

  • A Creates a new Point
  • B Tests whether o is a Point and, if so, extracts its components into x and y Correct
  • C Compares o with the origin
  • D Casts o to int
Correct Answer: Option B

Record patterns can be nested and used in switch with guards.

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