Skip to main content

Junior

A junior answer names the rule and the bug it prevents.

What is the difference between == and equals for objects?

== compares references. equals is the value comparison, and it must agree with hashCode when the object is used as a hash key. Compare strings with equals. Two equal strings are not required to be the same object.

When do you use an interface, and when an abstract class?

A class can implement several interfaces and extend one class. An interface names a capability, and it can include default methods. An abstract class can hold instance state that subclasses share. Use an interface unless that shared state is real.

What lives on the stack, and what lives on the heap?

A method's local primitives and references live in its stack frame. Objects are allocated on the heap, and the local variable holds a reference. When the method returns, the frame is gone. The object can be collected once nothing reachable points at it.

What is the difference between a checked exception and an unchecked exception?

A checked exception must be caught or declared. An unchecked exception extends RuntimeException and is not part of the signature. Use a checked exception for a recoverable condition the caller should know about. Do not use exceptions for ordinary branching.

What does final mean on a variable, a method, and a class?

A final variable cannot be assigned again. A final method cannot be overridden. A final class cannot be extended. final on a reference does not make the object immutable. Fields of that object can still change unless they are guarded too.

Why can building a string in a loop need a StringBuilder?

String is immutable, so repeated concatenation can copy the growing text. StringBuilder appends into a buffer. The compiler rewrites a simple concatenation in one expression. A loop driven by data still wants a builder.

Mid

A mid-level answer names the mechanism and a failure mode.

How does HashMap find a key, and what breaks if the key changes?

The map hashes the key, picks a bucket, then uses equals inside the bucket. If a field used by hashCode or equals changes after insertion, lookup searches the wrong bucket and misses the entry. Keys should be immutable in those fields. A high load resizes and rehashes.

What does synchronized guarantee, and what does it not?

A synchronized method locks the instance, or the Class object if it is static, so one thread at a time runs that block. It does not make two separately locked actions atomic. Locking on an object other code can also lock invites contention. Prefer a private lock, or a java.util.concurrent class, for shared state.

When is an ArrayList the wrong list, and what is the usual alternative?

ArrayList is a growable array: index access is cheap, and an insert in the middle shifts elements. LinkedList is a doubly linked list with poor random access, and it is rarely faster in practice. For a queue, ArrayDeque is the usual choice. Use ArrayList unless a measurement says otherwise.

What does type erasure mean for a List of strings at runtime?

The compiler checks the type argument and erases it. At runtime the list is a list of objects, with casts inserted where values are read. Two methods cannot be overloaded so that they differ only by a type argument. A raw type turns the check off.

Why can == succeed for some Integer values and fail for others?

int compares values. Integer is an object, so == compares references. Boxing reuses instances for at least -128 through 127, so == can pass in that range and fail outside it. Compare with equals, or unbox to int.

How do you close a resource when the block throws?

try-with-resources calls close when the block ends, including on an exception. The resource must implement AutoCloseable. If close also throws, that exception is attached to the original as a suppressed exception, so the first failure is not lost.

Senior

A senior answer names the tradeoff, the failure, and what to measure.

What does a service author need from the Java memory model?

Without a happens-before relationship, a thread can keep seeing a stale value written by another thread. volatile, locks, and the concurrent collections create that relationship. Final fields are visible after the constructor finishes, as long as this does not escape during construction. A plain write is not enough.

How do you investigate a long garbage-collection pause?

Read the collector log. Note the pause, how full the heap was before and after, and the allocation rate. A pause that tracks a growing old generation points at a leak or an unbounded cache. A pause where the heap recovers, with a high allocation rate, points at short-lived garbage. Change one thing and compare the same log.

How do you publish an object so other threads never see it half-built?

Finish the object, then publish one reference. Final fields are safely published when the constructor returns, if this does not escape while the constructor is still running. Handing out the reference and then calling setters lets another thread observe defaults.

When is ConcurrentHashMap a better choice than wrapping a HashMap with synchronizedMap?

ConcurrentHashMap allows concurrent reads and updates without locking the whole map, and a retrieval sees the most recently completed update. synchronizedMap locks the entire map, and a compound action such as check-then-act still needs an external lock. Use compute for a compound update on the concurrent map.

What do virtual threads change about blocking calls, and what do they leave unchanged?

Virtual threads, since Java 21, make a blocking I/O call cheap in operating-system threads, so a thread per request can wait on many calls. They do not make CPU-bound work faster. A scarce resource, such as a database, still needs a limit. On Java 21–23, avoid blocking inside synchronized, which pins the carrier thread; JDK 24 removed that limit (JEP 491).

Why is catching Exception and returning null a bug?

The caller cannot tell "not found" from "the database failed," and null then spreads. Catch the failure you can handle. Log an unexpected failure with its stack and let it surface as an error. Returning null deletes the cause.

Check that the candidate can code without AI

These questions show how a candidate talks about Java. They do not show the candidate writing the next change with no assistant. How to tell if a developer can code without AI explains the watched session.

What the candidate shows us is proctored tests, watched by a real person: a coding test with no AI allowed, a 2-hour build project with AI allowed, the Fire Drill (a live pair-programming session on a real-world problem), an English test, a thinking-skills test and a typing test. It also covers recorded reference checks. The menu is on Proctored tests. You pay for the tests you order. A real person watches.

When the answers are strong, Hire backend developers. Arca.ph is a network of remote engineers. Your own AI agent, such as Grok, Claude, or ChatGPT, searches and sorts that network. On the marketplace, the fee is a one-time 15% fee of first-year pay, only on hire, with a 3-month free replacement. Done for you is 35% of first-year pay, charged once on hire. Details are on pricing and how it works.

FAQ

How should these questions be used in an interview?

Ask two or three questions from the level you are hiring, then ask what would break. A useful interview is a conversation about a real constraint. It is not a recital of every question on this page. Use the watched coding check before you decide to hire.

What is the difference between a junior answer and a senior answer?

A junior answer names the rule and the common bug. A mid-level answer names the mechanism and one failure mode. A senior answer names a tradeoff, a failure they have seen, and what they would measure. Hire for the work the role will own, not for a perfect score on every question.

How do I check that the candidate can code without AI?

Questions do not show the candidate writing code. What the candidate shows us is proctored tests, watched by a real person: a coding test with no AI allowed, a 2-hour build project with AI allowed, the Fire Drill (a live pair-programming session on a real-world problem), an English test, a thinking-skills test and a typing test. It also covers recorded reference checks. The guide How to tell if a developer can code without AI explains the watched session.

Where do I look for engineers after the interview?

Open the backend developer hire page linked on this page. Java is one of the stacks listed for that role. Your own AI agent searches and sorts the Arca.ph network. You choose who to test and who to interview. Profiles are free to view once you sign up and sign the Arca.ph Client Agreement.

What does Arca.ph charge when I hire?

Arca.ph is a network of remote engineers. Your own AI agent, such as Grok, Claude, or ChatGPT, searches and sorts that network. On the marketplace, the fee is a one-time 15% fee of first-year pay, only on hire, with a 3-month free replacement. Done for you is 35% of first-year pay, charged once on hire.

Get started.

Profiles are free to view once you sign up and sign the Arca.ph Client Agreement.