Scrivio Interview library

Records

17 questions in 6 subtopics.

Record semantics

ConceptFoundations6 min read
What does the compiler generate for record Point(int x, int y) {}, and what restrictions do records have?
InternalsIntermediate7 min read
How are record equals, hashCode and toString implemented at the bytecode level, and what reflection support do records have?
ConceptPrincipal6 min read
Records were described as data carriers with transparent state rather than as a way to reduce boilerplate. Why does that distinction matter, and how should it guide where records are allowed in an organization's architecture?

Compact canonical constructors

CodingFoundations6 min read
Write a record Range(int lo, int hi) that rejects lo > hi, using a compact canonical constructor, and explain how it differs from a full canonical constructor.
DesignIntermediate6 min read
A record Email(String value) is used across a codebase. Where should normalisation (lowercase, trim) and validation go, and how do you avoid creating invalid instances through deserialization?
ScenarioAdvanced6 min read
A records-heavy event model has validation in compact constructors that calls external services and reads configuration. Events fail to deserialize during an outage. What design change do you make?

Records and immutability

DebuggingFoundations6 min read
A record Team(String name, List<String> members) is used as a map key. After a caller modifies the list, the map lookup fails. Why, and how do you fix it?
ConceptIntermediate6 min read
Are records immutable? Compare them with a hand-written immutable class and with Lombok @Value.
LeadershipPrincipal6 min read
Records, unmodifiable collections and value-based classes show a long trend in Java towards immutable data. How would you steer an organization whose codebase relies on mutable beans and setters towards immutable data over several years?

Records with Jackson and JPA

DebuggingIntermediate5 min read
After switching a DTO from a class to a record, Jackson output changes field names for a component called isActive, and a client breaks. Explain what to check.
ScenarioIntermediate6 min read
A team wants to use records for request and response DTOs in Spring MVC with Jackson, and also as JPA entities. What works and what does not?
ScenarioAdvanced6 min read
Your platform team wants a standard for API DTOs across fifty Spring Boot services, choosing between records, Lombok classes and hand-written classes. What do you decide and how do you roll it out?

Local records

CodingFoundations5 min read
Use a local record to sort orders by total value computed from line items, without adding a new top-level class.
ConceptIntermediate6 min read
Why are local records implicitly static, unlike local classes, and what does that mean for what they can reference?

When not to use records

DesignIntermediate6 min read
List cases where you should not use a record, and explain why for each.
LeadershipAdvanced6 min read
Teams want to convert hundreds of public API classes in a shared library to records. What compatibility issues do you consider before approving?
ConceptPrincipal6 min read
Records were deliberately limited: no extension, no extra instance fields and accessors that expose all state. Explain why the designers accepted these limits rather than building a general boilerplate reducer, and how this should shape your organization's guidance.