Why Java is platform independent not C or C++?

When we compile C source data, it generate native code which can be understood by current operating system.
When we move this source code to the other operating system, it can't be understood by operating system because of native code that means representation is change from O.S to O.S.
So C or C++ are platform dependent .

Now in case of java, after compilation we get byte code instead of native code. When we will run the byte code,
it is converted into native code with the help of JVM and then it will be executed.

So Java is platform independent and C or C++ is not platform independent.


  1. The java application runs on Java Virtual Machine which is not platform independent. It generates byte code which is platform independent. This feature makes Java platform independent.

  2. Language-C is a procedural language , C++ is a object oriented language whereas Java is a pure object oriented language. Platform Independent-C & C++ both are platform dependent that means you can't run and execute the code in any other operating system whereas Java is a platform independent language.