Java 8 preserves backward compatibility by adding new language and library features in ways that don't require existing code to change — most notably, default methods let the JDK extend interfaces like Collection with new capabilities such as stream() without breaking any class that already implemented those interfaces.
Key Points: • Default methods are the key enabling mechanism: they let interfaces gain new methods with a built-in implementation, so old implementing classes compile and run unchanged. • New syntax like lambda expressions and method references are purely additive — existing code using anonymous classes or explicit loops continues to compile and behave exactly as before. • Bytecode produced by Java 8 remains runnable on the JVM's standard class-loading and verification model, and Java 8 itself can generally still run class files compiled by earlier JDK versions. • The Stream API and new Date/Time API (java.time) were added as new packages alongside the old Collections Framework and java.util.Date, rather than replacing them, so legacy code using the old APIs keeps working. • Some very edge-case behavioral changes exist (such as permgen removal and certain reflection changes), but the language and core library additions were deliberately designed to be non-breaking for typical application code.
Example: A pre-Java-8 codebase using Collections.sort(list, comparator) and manual for-loops continues to compile and run unmodified under Java 8, even though the same codebase could now optionally adopt list.sort(comparator) or a stream pipeline instead.
Interview Tip: A concise interview answer is:
"Java 8 stayed backward compatible mainly through default methods, which let the JDK add new methods like stream() to existing interfaces such as Collection without forcing every implementing class to change. New features like lambdas and the Stream API were added alongside the old ways of doing things rather than replacing them, so pre-Java-8 code keeps compiling and running as-is."