Which statement about Java's `var` local-variable type inference (introduced in SE 10) is true in Java SE 17?
Java Fundamentals
Question · Easy
Given: ``` int a = 5; int b = 2; double c = a / b; System.out.println(c); ``` What is printed?
Introduction: The 1Z0-829 Exam
About the Java SE 17 Developer (1Z0-829) Exam
Study guide
What is the value of `s.length()` after `String s = "caf\u00e9";`?
Question · Medium
Tech Exam Prep Podcast
Listen on Spotify
Podcast
Which `String` method introduced before Java 17 returns `true` only when the string is empty or contains only whitespace characters as defined by `Character.isWhitespace`?
Given the text block: ``` String s = """ hello world """; ``` What is the value of `s` (using `<NL>` to represent a newline)?
Java Language Features
Which declaration of a Java 17 record is valid?
Chapter 1: Java Fundamentals & Language Basics
1.1 Primitive Types, Literals, Wrapper Classes, and Type Promotion/Casting
Which statement about sealed classes (finalized in Java 17) is correct?
Given: ``` Object o = "hello"; if (o instanceof String s) { System.out.println(s.length()); } ``` Which statement is true under Java 17 standard features?
Given the switch expression: ``` int day = 3; String name = switch (day) { case 1, 7 -> "weekend"; case 2, 3, 4, 5, 6 -> "weekday"; default -> "unknown"; }; ``` Which statement is true?
Control Flow
Which `for` loop will throw a `ConcurrentModificationException` when executed?
Collections
1.2 Local Variable Type Inference (`var`) Rules and Scoping
What does `List.of(1, 2, 3).add(4)` do?
Given: ``` Map<String,Integer> m = new HashMap<>(); m.put("a", 1); Integer v = m.getOrDefault("b", 0); m.merge("a", 5, Integer::sum); System.out.println(v + " " + m.get("a")); ``` What is printed?
Which generic method signature uses PECS (Producer Extends, Consumer Super) correctly to copy from a source list to a destination list?
Generics
Question · Hard
Why does the following code fail to compile? ``` List<Integer> ints = new ArrayList<>(); List<Number> nums = ints; ```
1.3 Operators, Precedence, Evaluation Order, and Short-Circuit Evaluation
Which call is a valid way to obtain a `Function<String, Integer>` that returns a string's length?
Functional Interfaces
Which built-in functional interface from `java.util.function` accepts an `int` and returns a `boolean`?
Given: ``` List<String> names = List.of("Ann", "Bob", "Cal"); int total = names.stream() .mapToInt(String::length) .sum(); System.out.println(total); ``` What does the program print?
Streams
Given: ``` Stream.of(1, 2, 3) .peek(System.out::println) .map(i -> i * 2); ``` What is printed when this statement executes?
1.4 Text Blocks, String Immutability, and StringBuilder APIs
Which `Collectors` call groups a `Stream<Employee>` by `dept` and counts employees per department?
Given an empty `List<Integer> empty = List.of();`, what does `empty.stream().reduce(Integer::sum)` return?
What does `Optional.of(null)` do?
Given: ``` LocalDate d = LocalDate.of(2026, 5, 6); LocalDate d2 = d.plusMonths(1).withDayOfMonth(31); ``` What is `d2`?
Date Time
Chapter 2: Program Flow & Decision Constructs
2.1 Conditional Branching with if/else and the Ternary Operator
Which `java.time` type best represents a moment in time on the timeline of UTC, with nanosecond precision and no time zone?
Given: ``` Path p = Path.of("reports", "2026", "q1.txt"); System.out.println(p); ``` What is printed on a Linux system?
Io
Which `Files` method efficiently reads a UTF-8 text file as a `Stream<String>` of lines without loading the whole file into memory?
Which try-with-resources declaration is valid in Java 17?
Exception Handling
2.2 Switch Statements and Switch Expressions
Which exception type does NOT have to be declared in a method's `throws` clause?
Given: ``` try { throw new RuntimeException("a"); } catch (RuntimeException e) { throw new IllegalStateException("b"); } finally { throw new Error("c"); } ``` Which throwable propagates out of this block?
Which statement about a Java module declared in `module-info.java` is correct?
Modules
Which JDK tool produces a custom runtime image containing only the modules an application needs?
2.3 Iteration Constructs, Loop Control, and Branching Labels
Which statement about a non-`static` nested class (inner class) is true?
What does `Integer.valueOf(127) == Integer.valueOf(127)` evaluate to, and why?
Given: ``` String a = "hi"; String b = new String("hi"); String c = b.intern(); System.out.println(a == b); System.out.println(a == c); ``` What is printed?
Which statement about Java arrays is correct?
Chapter 3: Object-Oriented Design & Class Mechanics
3.1 Class Declarations, Field/Method Signatures, and Access Modifiers
Given: ``` String s = "abc"; for (int i = 0; i < 3; i++) s += i; ``` Which claim is true?
Which switch expression is valid Java 17 STANDARD syntax (no `--enable-preview`)?
Which loop construct is best when iterating a `Map<K,V>` to read both keys and values without using streams?
Given: ``` List<Integer> nums = new ArrayList<>(List.of(3, 1, 4, 1, 5, 9)); Collections.sort(nums, Comparator.reverseOrder()); ``` What is `nums` after this code?
Loading more…