1Z0-819 — Frequently Asked Questions

Community-vetted answers to 20 common questions about this exam.

Questions from real practice questions

Each Q&A comes from a specific community question — follow the link for its full analysis.

Java var ArrayList Reassignment Compilation in 1Z0-819

Because var infers the full generic type ArrayList<String> for both listA and listC, making the assignment valid.

Then it would be a compile error because ListA is an undeclared identifier, but that is a typo not present in the intended exam code.

What Output Does This Java Program Print for Manager AA?

The toString() guards the manager reference (typically a ternary), so a null manager is rendered as the literal text "None" instead of being dereferenced.

The same toString() also appends the reports collection's size, and AA was created with two reports (BB and CC), so "Reports: 2" must appear in the line.

Valid BiPredicate Lambda Parameter Syntax

Java does not allow combining type-inferred parameters (var) with explicitly typed parameters in the same lambda expression to maintain clarity and consistency.

Yes, you can apply final to individual parameters, but it is often unnecessary for var-inferred parameters and can lead to confusion if not applied consistently.

How Many PreparedStatements and SQL Statements Execute in This JDBC Code?

The PreparedStatement is prepared once and then reused with new setInt/setString parameters before each executeUpdate, so only two objects exist even though it is executed more than once.

No resource is abandoned: JDBC releases a Connection's Statements and ResultSets when the Connection is closed, which the shown code does, so no leak occurs.

Which Stream Method Finds an Item With count Below Zero?

findAny() and findFirst() return Optional<Item>, not a boolean, so they cannot be used directly as an if condition; you would need to append isPresent().

allMatch returns true only if every item satisfies the predicate, so it answers a different question and is wrong when you just need to detect one item with count below zero.

What Does a for-Loop Stepping by Two Print?

The loop condition is tested before each pass; once the counter is no longer less than 10 the body is skipped, so 11 is never printed.

It lists the correct odd values but ignores the terminating bound, adding one iteration the loop never executes — a classic off-by-one trap.

Which BiPredicate Lambda Declaration Using var Is Valid?

JLS 15.27.1 makes var in lambda parameters all-or-nothing: if any parameter uses var, every parameter must use var. Mixing var with Integer is a compile-time error, so option A fails.

Yes. Any lambda parameter list that uses var, or that is implicitly typed with more than one parameter, must be enclosed in parentheses, which is why option C's bare var x, var y -> form is a syntax error.

Which return statements compile for a generic House method?

Generic types are invariant: House<Animal> is not a subtype of House<Dog>, so the return fails to compile. Supertype substitution only works when the declared type is the wildcard House<? super Dog>.

Yes. A raw constructor call is assignable to House<Dog> with just an unchecked-conversion warning, which is why the raw/diamond form is counted as one of the two correct answers.

What Is the Output of Console readLine and readPassword?

Console.readPassword suppresses echo while Java is typed, so the password appears only later when String.valueOf(password) is printed.

Direct concatenation or println's Object handling would produce a hash code like [C@... instead of Java; String.valueOf(char[]) prevents that.

What Happens When You Sort a List Created with List.of()?

List.of returns an immutable list, and List.sort() must replace elements in place; since the list cannot be modified, the JDK throws UnsupportedOperationException at runtime.

Option A, [Red:75, Red:100, Yellow:50, Yellow:75], because a mutable list can actually be sorted by hue and then by value.

← Back to 1Z0-819 Java SE 17 Developer Study Guide