What is Java NIO and how does it differ from traditional IO?
Why Interviewers Ask This
Interviewers ask this to evaluate whether you have the depth of knowledge needed to mentor others and lead technical decisions. The expected answer goes beyond definitions into practical implications and real-world consequences.
Answer
Java NIO (New I/O), introduced in Java 1.4, provides an alternative I/O API focused on non-blocking, buffer-oriented, and channel-based I/O. Traditional java.io is stream-oriented and blocking — each operation blocks until completed. NIO uses Channels (bidirectional connections) and Buffers (intermediate data containers) instead of streams. The key feature is the Selector — a single thread can monitor multiple channels for readiness (data available, connection complete), enabling one thread to handle thousands of connections. This is the basis of high-performance servers. Java 7's NIO.2 (java.nio.file) added the Files and Path APIs, greatly improving file system operations.
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last Java project, I used this when...' immediately makes your answer more credible and memorable.