Skip to content

1Z0-830 Java SE 21 Developer Professional Practice Questions

Prepare for 1Z0-830 with more than an answer.

254 questions in the full set17 sample questionsUpdated Jan 25, 2026
Exam fee
$245 USD
Level
Professional
Valid for
Does not expire
Domains covered on the exam 10
  1. Handling Date, Time, Text, Numeric and Boolean Values12%
  2. Controlling Program Flow10%
  3. Using Object-Oriented Concepts in Java25%
  4. Handling Exceptions8%
  5. Working with Arrays and Collections10%
  6. Working with Streams and Lambda Expressions15%
  7. Packaging and Deploying Java Code8%
  8. Managing Concurrent Code Execution12%
  9. Using Java I/O API8%
  10. Implementing Localization7%
  1. 1

    You are designing a module com.app.security that provides an implementation of a service com.app.api.Cipher. The implementation class is com.app.security.AesCipher.

    Which directive in module-info.java correctly declares this provision?

    Show answer details

    Correct answer: A

    The provides directive specifies the service interface (com.app.api.Cipher) and the with clause specifies the implementation class (com.app.security.AesCipher).

  2. 2

    What happens if a switch pattern matching block covers all possible subtypes of a sealed interface but does not include a default case?

    Show answer details

    Correct answer: A

    If the compiler can verify that a sealed hierarchy is exhaustively covered by the case labels (i.e., all permitted subtypes are handled), a default case is not required.

  3. 3

    You are using java.nio.file.Files.walk(Path start, int maxDepth, FileVisitOption... options) to traverse a directory structure. You want to ensure the traversal follows symbolic links.

    Which option should you pass?

    Show answer details

    Correct answer: A

    FileVisitOption.FOLLOW_LINKS is the enum constant used to request that symbolic links be followed during file traversal.

  4. 4

    Which statement about try-with-resources is TRUE regarding the order of closing resources?

    Show answer details

    Correct answer: A

    Resources declared in the try clause are closed in the reverse order of their creation/declaration. This ensures that if Resource B depends on Resource A, B is closed before A.

  5. 5

    When using Math.round(double a), what is the return type?

    Show answer details

    Correct answer: A

    Math.round(double) returns a long. Math.round(float) returns an int.

  6. 6

    You have a list of integers and want to use a parallel stream to compute the sum of squares.

    int sum = numbers.parallelStream()
    .mapToInt(i -> i * i)
    .reduce(0, (a, b) -> a + b);
    

    Is this operation thread-safe and correct?

    Show answer details

    Correct answer: A

    The reduction operation (a, b) -> a + b is associative and does not depend on shared mutable state, making it safe for parallel execution. The identity 0 is correct for addition.

  7. 7

    A financial application uses a sealed interface Transaction to represent various payment methods. The interface permits three record classes: CreditCard, BankTransfer, and DigitalWallet. You are writing a method to process these transactions using a switch expression with pattern matching.

    public sealed interface Transaction permits CreditCard, BankTransfer, DigitalWallet {}
    public record CreditCard(String pan, double amount) implements Transaction {}
    public record BankTransfer(String iban, double amount) implements Transaction {}
    public record DigitalWallet(String id, double amount) implements Transaction {}
    
    // In a service class:
    public String process(Transaction t) {
    return switch(t) {
    case CreditCard c when c.amount > 1000 -> "High Value CC";
    case CreditCard c -> "Standard CC";
    case BankTransfer b -> "Bank Transfer";
    // Missing case
    };
    }
    

    Which statement is true regarding the compilation of this code?

    Show answer details

    Correct answer: B

    Switch expressions must be exhaustive. Since Transaction is a sealed interface permitting CreditCard, BankTransfer, and DigitalWallet, all subtypes must be covered. The provided code handles CreditCard (both high value and standard) and BankTransfer, but it fails to handle DigitalWallet, causing a compilation error.

  8. 8

    You are developing a high-throughput web server using Java 21's Virtual Threads. You need to protect a shared resource using a locking mechanism. However, you want to avoid 'pinning' the virtual thread to the carrier thread, which can degrade performance during blocking operations.

    Which locking approach should you prefer?

    Show answer details

    Correct answer: B

    In Java 21, using synchronized blocks or methods inside a virtual thread can cause the virtual thread to be 'pinned' to its carrier thread if it performs a blocking operation (like I/O) while holding the monitor. This prevents the carrier thread from executing other virtual threads. ReentrantLock does not suffer from this pinning behavior and allows the virtual thread to unmount properly during blocking wait states.

Create an account to continue.