Amazon Interview Question
Software Engineer / DevelopersThe result of compiling a java source code is a class file. Java compiler transforms a source file into a class file. Class file is also called as bytecode. JVM them interprets the byte code and gives the output.
Assume a file called HelloWorld.java is compiled to HelloWorld.class by Java compiler in Windows machine. Then that HelloWorld.class file can be ran on any platform (Windows, Linux, Solaris) if it has JVM installed. This makes Java platform independent.
Thus people say: Write once, run anywhere.
As we know when any language translate source code into machine code directly then they will become an platform dependant but here's Java use an byte code which known as the mid of source code and machine code and that code can be run anywhere at any platform without any modification.so for these reason's Java is known as platform independent.
Java has build JVM for each type of platform and JAVA compiler converts it code into bytecodes, which is uniquely interpreted by each JVM, so that makes JAVA platform independent.
- Hello June 16, 2008