What do Java coding rounds in interviews actually test, beyond whether you can write the algorithm?
The algorithm is the easy part — most candidates can write two-sum. What the round really assesses is how you work. Can you clarify the requirements before writing anything, and can you notice the edge cases you have been asked about? Can you decompose the problem rather than attacking it as one blob? Will you test your own work before you say it is done?
The classic failure is a candidate who silently codes for twenty minutes and then has to be asked what the code does. A second classic is a candidate who writes a solution, never tests it, and does not notice that it returns the wrong answer for an empty input. Both are far more expensive to an employer than a slightly suboptimal algorithm.
What is specifically Java-flavoured. Whether you reach for the right collection without hesitating. Whether you handle null without scattering null checks everywhere. Whether you write code that a colleague could maintain — clear names, no unnecessary cleverness. And whether you notice the performance implications of the thing you just wrote, such as a lookup inside a nested loop over a list where a map would make it constant time.
The other half is communication. Saying your plan out loud before coding costs nothing and gives the interviewer the chance to correct a misunderstanding early. Saying what you are about to test, and then actually testing it, is the single most effective thing you can do in a coding round.