skip to content

Modern / Recent Platform Additions

The recent platform additions that do not belong to any older topic: JShell, the standard HTTP client, single-file execution, helpful NullPointerExceptions, sequenced collections, and the foreign-memory and vector APIs. Interviewers use them to gauge whether you have kept up past Java 8.

part ofJavaread it →
on this pageshow

explore

questions

page 2 of 2

How do you call a native C function from Java with the Linker (downcall), and what is an upcall?

level: seniorimportance: should knowfreq 42%

basics

~20 s

A downcall is Java calling into C: you get the Linker, look up the function's address, describe its signature with a FunctionDescriptor, and get a MethodHandle you can invoke. An upcall is the reverse — you wrap a Java method as a function pointer so C can call back into Java.

open as a page

How do MemoryLayout and VarHandle enable structured, type-safe access to native memory (e.g. reading a C struct)?

level: seniorimportance: should knowfreq 40%

basics

~20 s

A MemoryLayout describes the shape of memory — the fields, their types, sizes, and offsets — like a blueprint of a C struct. From a layout you derive a VarHandle, a precomputed accessor that reads or writes one field at the right offset, so you don't compute byte offsets by hand.

open as a page

What out-of-the-box behaviors does the java.net.http client provide for HTTP/2, redirects, timeouts, and authentication?

level: seniorimportance: should knowfreq 48%

basics

~20 s

The client speaks HTTP/2 by default (falling back to HTTP/1.1), can follow redirects based on a configured policy, supports a connect timeout on the client and a per-request timeout, and can authenticate via a configured Authenticator or by adding an Authorization header yourself.

open as a page

Which modern Java features do you use in your own code, and why those?

level: seniorimportance: should knowfreq 60%

basics

~20 s

A strong answer picks a few and justifies each: records and sealed types with pattern switch for compiler-checked data models, virtual threads for blocking I/O at scale, text blocks for readable literals, and no preview features in production.

open as a page

What does reversed() return, and how does it behave with respect to the underlying collection?

level: seniorimportance: should knowfreq 40%

basics

~20 s

reversed() returns a view of the same collection in opposite order, not a copy. It is backed by the original, so reads reflect later changes, and supported writes on the view (like addFirst) modify the original.

open as a page

What are masks in the Vector API, and how do they let you handle loop tails and conditional (branchless) computation?

level: seniorimportance: should knowfreq 25%

basics

~20 s

A mask is a per-lane on/off switch. It tells an operation which lanes to actually apply to. You use it to safely process a partial final chunk of an array and to do if-style logic without branches by selecting values per lane.

open as a page

Why does the FFM API supersede JNI and sun.misc.Unsafe, and what trade-offs and risks should you weigh before adopting it?

level: principalimportance: should knowfreq 35%

basics

~20 s

FFM replaces JNI (which needed fragile handwritten C glue) and Unsafe (an internal, crash-prone API) with one safe, pure-Java, standard API. It adds bounds and lifetime safety, no separate C build step, and good performance — but it still crosses a native boundary, needs the right JDK and sometimes runtime flags, and native calls can still crash if signatures are wrong or memory is misused.

open as a page

What does String.repeat(int) do, and what are its edge cases and uses?

level: juniorimportance: nice to knowfreq 40%

basics

~10 s

repeat(n) (Java 11) returns a new string formed by concatenating this string n times. "ab".repeat(3) is "ababab". repeat(0) gives "", and a negative count throws IllegalArgumentException.

open as a page

What is Java's Class-File API (java.lang.classfile), and why did the JDK add it when ASM already existed?

level: middleimportance: nice to knowfreq 24%

basics

~20 s

The Class-File API (java.lang.classfile, final in Java 24) is the JDK's standard library for parsing, generating and transforming class files. It exists so tools and the JDK track the class-file format without waiting on a bundled library such as ASM.

open as a page

What does HTTP/3 change in Java's java.net.http client since JDK 26, and how do you ask for it?

level: middleimportance: nice to knowfreq 24%

basics

~20 s

JDK 26 adds HTTP/3 over QUIC to java.net.http, but it stays opt-in: HTTP/2 remains the default. Set HttpClient.Version.HTTP_3 on the client or the request; sending code is unchanged, and the client still falls back unless told not to.

open as a page

What is Java's LazyConstant, a preview API at JDK 27, and what does it add over a holder class or double-checked locking?

level: middleimportance: nice to knowfreq 25%

basics

~20 s

LazyConstant, a JDK 27 preview API, runs its computing function at most once, on first get(). Unlike a holder class it works on instance fields; unlike double-checked locking its content can be constant-folded when reached from a static final field.

open as a page

How does single-file source execution compare with JShell, and when would you choose each?

level: middleimportance: nice to knowfreq 35%

basics

~20 s

JShell is an interactive prompt (REPL) where you type and evaluate code line by line. Single-file execution runs a whole small program from a .java file in one command. Use JShell to explore; use single-file mode to run a script.

open as a page

In Java's Class-File API, how do models, builders and transforms fit together when rewriting a class, and how does that differ from ASM's visitors?

level: seniorimportance: nice to knowfreq 13%

basics

~20 s

Immutable models expose a class as a sequence of elements, builders accept those same elements, and a transform decides for each element whether to keep, drop or replace it. ASM uses one visitor structure for reading and writing, driven by callbacks.

open as a page

What are the limitations, costs, and security trade-offs of Helpful NullPointerExceptions in production?

level: seniorimportance: nice to knowfreq 30%

basics

~20 s

It only improves the message, never prevents the NPE. Building the message costs a little, but only when an NPE actually happens. The message can include variable names, so don't show it to untrusted users.

open as a page

How do Helpful NullPointerExceptions compare to other null-handling approaches, and where do they fit in a null-safety strategy?

level: seniorimportance: nice to knowfreq 28%

basics

~10 s

They are a debugging aid, not a prevention tool. You still use Optional, null checks, requireNonNull, and annotations to avoid NPEs; the helpful message just tells you fast where one slipped through.

open as a page

Why was java.net.http introduced to replace HttpURLConnection, and what does it do better?

level: seniorimportance: nice to knowfreq 40%

basics

~10 s

HttpURLConnection is an old, awkward, blocking-only API with no HTTP/2 support. java.net.http replaces it with a modern, immutable builder-based client that supports HTTP/2, WebSocket, async calls via CompletableFuture, and pluggable request/response body handling.

open as a page

What are forward references in JShell, and how does JShell handle a method that calls something not yet defined?

level: seniorimportance: nice to knowfreq 25%

basics

~20 s

A forward reference is when a method you define refers to a variable, method, or type that doesn't exist yet. JShell accepts the definition, marks it as not-yet-runnable, and makes it work automatically once you define the missing piece.

open as a page

When should you reach for JShell versus a scratch class or unit test, and what are its limits?

level: seniorimportance: nice to knowfreq 22%

basics

~20 s

Use JShell for quick, throwaway experiments: trying an API, checking what a snippet returns, or teaching. For anything you need to keep, repeat reliably, or run with your project's dependencies and build, use a scratch class or a unit test instead.

open as a page

How do List.ofLazy, Map.ofLazy and Set.ofLazy extend LazyConstant, what happens when a computing function throws, and what changed from StableValue?

level: seniorimportance: nice to knowfreq 12%

basics

~20 s

List.ofLazy, Map.ofLazy and Set.ofLazy behave like one lazy constant per index, key or candidate. At JDK 27 a throwing function leaves that slot in an error state: NoSuchElementException on each access, never recomputed. JDK 26 turned StableValue into LazyConstant, minus its setters.

open as a page

What do String.indent(int) and String.transform(Function) do (Java 12), and when would you use each?

level: seniorimportance: nice to knowfreq 35%

basics

~20 s

indent(n) (Java 12) adds n spaces of indentation to each line (or removes up to n with a negative value) and normalizes line endings to \n, ensuring each line ends with a newline. transform(fn) applies a function to the whole string and returns its result, letting you chain custom operations fluently.

open as a page

How do you turn a Java source file into an executable Unix script using single-file execution, and why is the --source flag needed?

level: seniorimportance: nice to knowfreq 30%

basics

~20 s

Add a shebang line #!/path/to/java --source 21 as the first line of an extension-less file, make it executable with chmod +x, and run ./myscript. The --source flag is required because, without a .java extension, the launcher needs to be told to use source mode and which language level.

open as a page

Why is the Vector API still an incubating module, what does that mean for using it, and how does it relate to Project Valhalla?

level: seniorimportance: nice to knowfreq 22%

basics

~20 s

Incubating means it is an unfinished, opt-in module whose API can change between Java releases. You must explicitly enable it. It is waiting on Project Valhalla so vectors can become lightweight value types with no heap overhead before it is finalized.

open as a page

As a library author, when should you expose SequencedCollection in an API, and what are the trade-offs?

level: principalimportance: nice to knowfreq 22%

basics

~20 s

Use SequencedCollection in a signature when callers genuinely need a defined order plus end access, but you don't want to lock them into List. Accept it as a parameter to be permissive; return it (or a narrower type) when order is part of your contract. Don't use it if order is irrelevant.

open as a page

Where does single-file source execution sit in Java's evolution toward lower-ceremony programs, and how have JEP 458 and implicit main methods extended it?

level: principalimportance: nice to knowfreq 22%

basics

~20 s

Single-file execution (Java 11) was an early step to make Java easier for small programs. Later, JEP 458 let you run multi-file programs from source, and implicit classes plus instance main methods removed most boilerplate, so a beginner can run a tiny program from source with almost no ceremony.

open as a page

As an architect, when should you adopt the Vector API versus relying on JIT auto-vectorization or a native library? What are the costs and risks?

level: principalimportance: nice to knowfreq 18%

basics

~20 s

Use it only for hot, data-parallel numeric kernels where you have measured a real bottleneck and the JIT is not vectorizing reliably. For small or branchy code, let the JIT handle it; for heavy, well-tuned math, a native BLAS library may beat it. Weigh the cost of an unstable, incubating API.

open as a page

showing 31–55 of 55