Quiz2Know

IT

Java 21 language features

Records, pattern matching, virtual threads, and more from the Java 21 LTS.

This is a free, 6-question multiple-choice quiz. Answer each question to see whether you got it right, with an explanation for every answer. There is no sign-up and no time limit — take it as many times as you like, and scroll down for the full answer key once you are done.

Question 1 of 6

0 correct

Java 21 is which kind of release?

Press A–D to choose · Enter to submit

Answer key & explanations

Every question in this quiz, with the correct answer marked and an explanation of why it is right. Use it to revise before or after taking the quiz above.

  1. 1.Java 21 is which kind of release?

    • AA preview-only release
    • BA Long-Term Support (LTS) release✓ Correct
    • CA point release of Java 17
    • DA beta release

    Correct answer: A Long-Term Support (LTS) release

    Java 21 is an LTS release, like 17 and 11 before it.

  2. 2.What does JEP 444 finalize in Java 21?

    • ASealed classes
    • BVirtual threads✓ Correct
    • CText blocks
    • DRecords

    Correct answer: Virtual threads

    JEP 444 finalizes virtual threads, lightweight threads managed by the JVM instead of the OS.

  3. 3.Record patterns (JEP 440) let you do what?

    • ADestructure a record directly in a pattern, e.g. in a switch or instanceof✓ Correct
    • BMake a class immutable at compile time
    • CGenerate equals()/hashCode() automatically
    • DDeclare a record without a constructor

    Correct answer: Destructure a record directly in a pattern, e.g. in a switch or instanceof

    Record patterns let you match and extract a record’s components in one step, e.g. `case Point(int x, int y) ->`.

  4. 4.Which interface do the new Sequenced Collections (JEP 431) add?

    • ASequencedCollection✓ Correct
    • BOrderedList
    • CIndexedCollection
    • DLinkedSet

    Correct answer: SequencedCollection

    JEP 431 introduces `SequencedCollection`, `SequencedSet`, and `SequencedMap`, adding well-defined encounter order and first/last accessors.

  5. 5.Pattern matching for switch (JEP 441) was promoted to what status in Java 21?

    • ARemoved
    • BPreview
    • CFinal (standard) feature✓ Correct
    • DDeprecated

    Correct answer: Final (standard) feature

    JEP 441 finalizes pattern matching for switch after several rounds of preview in earlier versions.

  6. 6.What is the main benefit virtual threads give a typical blocking I/O server application?

    • ALower memory usage per request and far higher concurrency without rewriting to async code✓ Correct
    • BFaster CPU-bound computation
    • CSmaller compiled bytecode
    • DAutomatic parallelization of loops

    Correct answer: Lower memory usage per request and far higher concurrency without rewriting to async code

    Virtual threads let you keep a simple one-thread-per-request style while scaling to huge numbers of concurrent blocked threads cheaply.

More free quizzes