Question 1
Topic: Working with Java data types
Skill tested: Applies local variable type inference to explicitly typed lambda parameters.
A telemetry service uses Java 11 and must reject malformed records before publishing them. The records are stored in a `List`, and the team wants to use `var` for local variables while retaining a clearly typed lambda parameter for review. Which fragment compiles and preserves the intended filtering behavior?
In Java 11, `var` is permitted for a local variable and for an implicitly typed lambda parameter, but a lambda parameter list must be consistently implicit or explicitly typed. Therefore `(record) -> ...` is valid here, and the stream result can be collected with `Collectors.toList()`. `Stream.toList()` was added after Java 11. Mixing `var` with an explicitly typed parameter is illegal, as is mixing `var` and an omitted type in the same parameter list.