Interview Questions

How is Java Platform independent?

Java is a Platform independent language.

The source in Java is created with a ".java" file. This file is then compiled using the Java Compiler which produces the ".class" file. The class file is created with the byte codes as per Java specifications and is platform neutral.

This class file is then executed by the Java Virtual machine (JVM) which is Platform dependent. What it means is, the same class file can be executed in all platforms but with different JVM's which are specific to Operating system. By this way, the same Java code is written once and can be executed in different platforms. Hence it is called Platform independent.