ODNYX.
Tutorials
Java
CSS
Database
DevOps
Spring
Design Patterns
References
Subscribe
Java
CSS
Database
DevOps
Spring
Design Patterns
Java Records — Quick Check
1. What does declaring `public record Point(int x, int y) {}` give you automatically?
Only a constructor
A constructor, accessors, equals(), hashCode(), and toString()
Nothing — you still need to write everything by hand
Only equals() and hashCode()
2. Can you add a setter to change a record's field after it's created?
Yes, records generate setters automatically
No, records are immutable and have no setters
Only if the field is declared public
Only for numeric fields
Check answers
❮ Home
Next: Java Class Types Interview Questions (Enum, Record) ❯