Practice / jvm

Java practice

Every Java exercise, built from a topic you can open beside it.

81 exercises runs offline
jvm Quiz new Which retention policy applies when an annotation interface has no `@Retention`? Attach structured metadata to Java declarations and type uses, then consume it correctly through compiler checks, processing, or reflection. beginner 1 min · from Annotations jvm Quiz new What does `@Inherited` make a subclass query inherit? Attach structured metadata to Java declarations and type uses, then consume it correctly through compiler checks, processing, or reflection. intermediate 1 min · from Annotations jvm Predict the output new What does this program print? Attach structured metadata to Java declarations and type uses, then consume it correctly through compiler checks, processing, or reflection. intermediate 2 min · from Annotations jvm Review AI code new Review generated role dispatcher Attach structured metadata to Java declarations and type uses, then consume it correctly through compiler checks, processing, or reflection. advanced 6 min · from Annotations jvm Spot the bug new Spot the bug in the scheduled job annotation Attach structured metadata to Java declarations and type uses, then consume it correctly through compiler checks, processing, or reflection. beginner 4 min · from Annotations jvm Quiz new Why can a Java String containing one displayed symbol have length 2? The boundaries between Java primitives and references, conversion and boxing rules, and type mistakes that break production code. beginner 1 min · from Data types jvm Predict the output new What does this program print? The boundaries between Java primitives and references, conversion and boxing rules, and type mistakes that break production code. intermediate 2 min · from Data types jvm Review AI code new Review generated invoice total The boundaries between Java primitives and references, conversion and boxing rules, and type mistakes that break production code. advanced 6 min · from Data types jvm Spot the bug new Spot the bug in the storage estimate The boundaries between Java primitives and references, conversion and boxing rules, and type mistakes that break production code. beginner 4 min · from Data types jvm Quiz new Which widening primitive conversion can lose numeric precision? The boundaries between Java primitives and references, conversion and boxing rules, and type mistakes that break production code. intermediate 1 min · from Data types jvm Quiz new What must a method do when it calls code that may throw a checked exception? How Java exceptions propagate, where checked and unchecked failures belong, how resources close, and which failure-handling bugs generated code introduces. beginner 1 min · from Exceptions jvm Predict the output new What does this program print? How Java exceptions propagate, where checked and unchecked failures belong, how resources close, and which failure-handling bugs generated code introduces. beginner 2 min · from Exceptions jvm Review AI code new Review generated order importer How Java exceptions propagate, where checked and unchecked failures belong, how resources close, and which failure-handling bugs generated code introduces. advanced 6 min · from Exceptions jvm Spot the bug new Spot the bug in the blocking worker How Java exceptions propagate, where checked and unchecked failures belong, how resources close, and which failure-handling bugs generated code introduces. intermediate 4 min · from Exceptions jvm Quiz new In try-with-resources, the body throws A and close() then throws B. What normally propaga… How Java exceptions propagate, where checked and unchecked failures belong, how resources close, and which failure-handling bugs generated code introduces. intermediate 1 min · from Exceptions jvm Quiz new Which change makes a later read of a local variable definitely assigned? Understand program structure, variable scope, expression evaluation, and control flow in Java 25 without common short-circuit and boundary bugs. beginner 1 min · from Java language fundamentals jvm Predict the output new What does this program print? Understand program structure, variable scope, expression evaluation, and control flow in Java 25 without common short-circuit and boundary bugs. beginner 2 min · from Java language fundamentals jvm Review AI code new Review generated batch label planner Understand program structure, variable scope, expression evaluation, and control flow in Java 25 without common short-circuit and boundary bugs. intermediate 6 min · from Java language fundamentals jvm Spot the bug new Spot the bug in the total loop Understand program structure, variable scope, expression evaluation, and control flow in Java 25 without common short-circuit and boundary bugs. beginner 4 min · from Java language fundamentals jvm Quiz new How does a block rule return a value from a Java switch expression? Understand program structure, variable scope, expression evaluation, and control flow in Java 25 without common short-circuit and boundary bugs. beginner 1 min · from Java language fundamentals jvm Quiz new Which signature accepts an `Integer` source and a `Number` destination while preserving t… Java generics express type relationships across an API; understand bounds, wildcards, and erasure to design flexible, type-safe interfaces. intermediate 1 min · from Generics jvm Quiz new Which operation is legal because the tested type is reifiable? Java generics express type relationships across an API; understand bounds, wildcards, and erasure to design flexible, type-safe interfaces. intermediate 1 min · from Generics jvm Predict the output new What does this program print? Java generics express type relationships across an API; understand bounds, wildcards, and erasure to design flexible, type-safe interfaces. intermediate 2 min · from Generics jvm Review AI code new Review generated reading merger Java generics express type relationships across an API; understand bounds, wildcards, and erasure to design flexible, type-safe interfaces. advanced 6 min · from Generics jvm Spot the bug new Spot the bug in the raw List Java generics express type relationships across an API; understand bounds, wildcards, and erasure to design flexible, type-safe interfaces. intermediate 4 min · from Generics jvm Quiz new A local class captures List<String> events. Which operation is allowed while events remai… Distinguish nested and inner classes, understand enclosing instances, local capture, and anonymous classes, and avoid lifecycle and semantic bugs. intermediate 1 min · from Inner classes jvm Quiz new Which statement uses the Java 25 specification terms correctly? Distinguish nested and inner classes, understand enclosing instances, local capture, and anonymous classes, and avoid lifecycle and semantic bugs. beginner 1 min · from Inner classes jvm Predict the output new What does this program print? Distinguish nested and inner classes, understand enclosing instances, local capture, and anonymous classes, and avoid lifecycle and semantic bugs. beginner 2 min · from Inner classes jvm Review AI code new Review generated job callback factory Distinguish nested and inner classes, understand enclosing instances, local capture, and anonymous classes, and avoid lifecycle and semantic bugs. advanced 6 min · from Inner classes jvm Spot the bug new Spot the bug in the inner-class factory Distinguish nested and inner classes, understand enclosing instances, local capture, and anonymous classes, and avoid lifecycle and semantic bugs. intermediate 4 min · from Inner classes jvm Quiz new Which change definitely makes a valid functional interface stop being a functional interf… Java interfaces define replaceable behavior contracts; learn member rules, default-method conflicts, functional interfaces, and safe API evolution. intermediate 1 min · from Interfaces jvm Quiz new What is true of `List<String> EVENTS = new ArrayList<>();` declared in an interface? Java interfaces define replaceable behavior contracts; learn member rules, default-method conflicts, functional interfaces, and safe API evolution. beginner 1 min · from Interfaces jvm Predict the output new What does this program print? Java interfaces define replaceable behavior contracts; learn member rules, default-method conflicts, functional interfaces, and safe API evolution. beginner 2 min · from Interfaces jvm Review AI code new Review generated token authorizer Java interfaces define replaceable behavior contracts; learn member rules, default-method conflicts, functional interfaces, and safe API evolution. advanced 6 min · from Interfaces jvm Spot the bug new Spot the bug in the default-method class Java interfaces define replaceable behavior contracts; learn member rules, default-method conflicts, functional interfaces, and safe API evolution. intermediate 4 min · from Interfaces jvm Quiz new Which feature in this topic became final specifically in Java 17? The stable language features available at the Java 17 source level, with runnable examples and migration boundaries that prevent version drift. beginner 1 min · from Java 17 features jvm Predict the output new What does this Java 17 program print? The stable language features available at the Java 17 source level, with runnable examples and migration boundaries that prevent version drift. beginner 2 min · from Java 17 features jvm Predict the output new What does this program print about the record component? The stable language features available at the Java 17 source level, with runnable examples and migration boundaries that prevent version drift. intermediate 2 min · from Java 17 features jvm Review AI code new Review generated CSV row importer The stable language features available at the Java 17 source level, with runnable examples and migration boundaries that prevent version drift. advanced 6 min · from Java 17 features jvm Spot the bug new Spot the bug in the Java 17 switch The stable language features available at the Java 17 source level, with runnable examples and migration boundaries that prevent version drift. intermediate 4 min · from Java 17 features jvm Predict the output new What does this stable Java 21 program print? Java 21's stable language and concurrency features, its preview boundary, and the version drift to catch when reviewing old examples on Java 25. beginner 2 min · from Java 21 features jvm Quiz new What does `list.reversed()` return in the Java 21 sequenced-collection API? Java 21's stable language and concurrency features, its preview boundary, and the version drift to catch when reviewing old examples on Java 25. beginner 1 min · from Java 21 features jvm Review AI code new Review generated Java 21 order loader Java 21's stable language and concurrency features, its preview boundary, and the version drift to catch when reviewing old examples on Java 25. advanced 6 min · from Java 21 features jvm Spot the bug new Spot the bug in the virtual-thread task Java 21's stable language and concurrency features, its preview boundary, and the version drift to catch when reviewing old examples on Java 25. intermediate 4 min · from Java 21 features jvm Quiz new Which command proves that source uses only stable Java 21 language and Java SE APIs? Java 21's stable language and concurrency features, its preview boundary, and the version drift to catch when reviewing old examples on Java 25. beginner 1 min · from Java 21 features jvm Quiz new A service starts one virtual thread per request, but its database accepts only 30 concurr… Java 21's stable language and concurrency features, its preview boundary, and the version drift to catch when reviewing old examples on Java 25. intermediate 1 min · from Java 21 features jvm Quiz new Which design best preserves an account invariant that the balance never becomes negative? Java objects organize state and behavior behind explicit boundaries; learn invariants, dynamic dispatch, substitutability, and composition. beginner 1 min · from Object-oriented programming jvm Predict the output new What does this program print? Java objects organize state and behavior behind explicit boundaries; learn invariants, dynamic dispatch, substitutability, and composition. beginner 2 min · from Object-oriented programming jvm Quiz new Which statement correctly distinguishes reference identity from value equality? Java objects organize state and behavior behind explicit boundaries; learn invariants, dynamic dispatch, substitutability, and composition. intermediate 1 min · from Object-oriented programming jvm Review AI code new Review generated member account Java objects organize state and behavior behind explicit boundaries; learn invariants, dynamic dispatch, substitutability, and composition. advanced 12 min · from Object-oriented programming jvm Spot the bug new Spot the bug in the constructor hierarchy Java objects organize state and behavior behind explicit boundaries; learn invariants, dynamic dispatch, substitutability, and composition. intermediate 4 min · from Object-oriented programming jvm Quiz new What happens to a component parameter rebound inside a compact constructor? Model transparent data carriers with records, including derived members, compact constructors, shallow immutability, and record-pattern boundaries. intermediate 1 min · from Records jvm Predict the output new What does this program print? Model transparent data carriers with records, including derived members, compact constructors, shallow immutability, and record-pattern boundaries. beginner 2 min · from Records jvm Quiz new Without `case null`, what happens when a pattern switch over records receives null? Model transparent data carriers with records, including derived members, compact constructors, shallow immutability, and record-pattern boundaries. intermediate 1 min · from Records jvm Review AI code new Review generated archive request key Model transparent data carriers with records, including derived members, compact constructors, shallow immutability, and record-pattern boundaries. advanced 6 min · from Records jvm Spot the bug new Spot the bug in the HashMap record key Model transparent data carriers with records, including derived members, compact constructors, shallow immutability, and record-pattern boundaries. intermediate 4 min · from Records jvm Quiz new A class declares `void setLimit(int value)`. What happens when code calls `getMethod("set… Inspect runtime types and invoke members in Java 25 while handling exact lookup, module access, exception wrapping, and dynamic proxies correctly. beginner 1 min · from Reflection jvm Quiz new Where is an exception thrown normally by a method invoked through `Method.invoke()`? Inspect runtime types and invoke members in Java 25 while handling exact lookup, module access, exception wrapping, and dynamic proxies correctly. intermediate 1 min · from Reflection jvm Predict the output new What does this program print? Inspect runtime types and invoke members in Java 25 while handling exact lookup, module access, exception wrapping, and dynamic proxies correctly. beginner 2 min · from Reflection jvm Review AI code new Review a generated command dispatcher Inspect runtime types and invoke members in Java 25 while handling exact lookup, module access, exception wrapping, and dynamic proxies correctly. advanced 6 min · from Reflection jvm Spot the bug new Spot the bug in reflective method lookup Inspect runtime types and invoke members in Java 25 while handling exact lookup, module access, exception wrapping, and dynamic proxies correctly. intermediate 4 min · from Reflection jvm Quiz new Which declarations can an ordinary class directly permitted by a sealed class use? Model closed type hierarchies with sealed, permits, and exhaustive pattern switches while handling extension, modules, and API evolution correctly. beginner 1 min · from Sealed classes jvm Quiz new Where may a directly permitted subtype be declared? Model closed type hierarchies with sealed, permits, and exhaustive pattern switches while handling extension, modules, and API evolution correctly. intermediate 1 min · from Sealed classes jvm Predict the output new What does this program print? Model closed type hierarchies with sealed, permits, and exhaustive pattern switches while handling extension, modules, and API evolution correctly. beginner 2 min · from Sealed classes jvm Review AI code new Review generated event audit hierarchy Model closed type hierarchies with sealed, permits, and exhaustive pattern switches while handling extension, modules, and API evolution correctly. advanced 6 min · from Sealed classes jvm Spot the bug new Spot the bug in the sealed hierarchy Model closed type hierarchies with sealed, permits, and exhaustive pattern switches while handling extension, modules, and API evolution correctly. intermediate 4 min · from Sealed classes jvm Quiz new A persisted protocol key must use locale-neutral uppercase. Which expression states that … Java String value semantics, UTF-16 indexing, pooling, comparison, Unicode boundaries, encoding, and efficient construction. intermediate 1 min · from Strings jvm Quiz new For String text = "A🚗", which statement is correct? Java String value semantics, UTF-16 indexing, pooling, comparison, Unicode boundaries, encoding, and efficient construction. beginner 1 min · from Strings jvm Predict the output new What does this program print? Java String value semantics, UTF-16 indexing, pooling, comparison, Unicode boundaries, encoding, and efficient construction. beginner 2 min · from Strings jvm Review AI code new Review generated CSV row formatter Java String value semantics, UTF-16 indexing, pooling, comparison, Unicode boundaries, encoding, and efficient construction. advanced 6 min · from Strings jvm Spot the bug new Spot the bug in the field parser Java String value semantics, UTF-16 indexing, pooling, comparison, Unicode boundaries, encoding, and efficient construction. intermediate 4 min · from Strings jvm Quiz new A class implements `Decoder<Integer>` by declaring `Integer decode(String)`. Why may refl… Understand how Java generics become executable JVM types, and where type tokens, bridge methods, heap pollution, and runtime checks meet their limits. intermediate 1 min · from Type erasure jvm Quiz new What is the erasure of `T` in `T extends CharSequence & Comparable<T>`? Understand how Java generics become executable JVM types, and where type tokens, bridge methods, heap pollution, and runtime checks meet their limits. intermediate 1 min · from Type erasure jvm Predict the output new What does this program print? Understand how Java generics become executable JVM types, and where type tokens, bridge methods, heap pollution, and runtime checks meet their limits. beginner 2 min · from Type erasure jvm Review AI code new Review a generated decoder adapter Understand how Java generics become executable JVM types, and where type tokens, bridge methods, heap pollution, and runtime checks meet their limits. advanced 6 min · from Type erasure jvm Spot the bug new Spot the bug in the generic list helper Understand how Java generics become executable JVM types, and where type tokens, bridge methods, heap pollution, and runtime checks meet their limits. intermediate 4 min · from Type erasure jvm Quiz new Why can a private `<T> void swap(List<T> values, ...)` helper accept a `List<?>` from a p… Java wildcards define safe read and write capabilities at generic API boundaries; use PECS, capture helpers, and named type parameters without unsafe casts. advanced 1 min · from Wildcards and PECS jvm Predict the output new What does this program print? Java wildcards define safe read and write capabilities at generic API boundaries; use PECS, capture helpers, and named type parameters without unsafe casts. intermediate 2 min · from Wildcards and PECS jvm Review AI code new Review a generated wildcard transfer Java wildcards define safe read and write capabilities at generic API boundaries; use PECS, capture helpers, and named type parameters without unsafe casts. advanced 8 min · from Wildcards and PECS jvm Spot the bug new Spot the bug in the wildcard copy method Java wildcards define safe read and write capabilities at generic API boundaries; use PECS, capture helpers, and named type parameters without unsafe casts. intermediate 4 min · from Wildcards and PECS jvm Quiz new Given `List<? extends Number> values`, which operation is guaranteed to type-check? Java wildcards define safe read and write capabilities at generic API boundaries; use PECS, capture helpers, and named type parameters without unsafe casts. beginner 1 min · from Wildcards and PECS