Most of the people have confusion regarding this Question. So I have decided to write something on this topic. Now we will go step by step whats this
What a Platform means to us
The operating system installed on the computer is known to be a platform. Each and every operating system have different structure and format. These operating systems (platforms) differs on the basis of the following factors- Like the way they execute the files.
- On the basis of system kernels
- The way the optimize the system for best performance and make use of processor
- On the basis of different file extensions, etc
For example, Windows operating systems executes .exe files.
Linux here everything is a file. And also here there is no specific extension. Any file can be executable here
similarly, we have Unix and Mac Os that have their own file extensions.
Platform Independent Vs Platform Dependent
Platform Independent means the program that we have developed can run / execute (show results) on any platform. That is on any operating system.
Platform Dependent means the program / software that we have developed can run /execute (show results) on a specific platform. That is on a specific operating system.
Why Java is Platform Independent and C, C++ not !!
The programming language like C and C++ do not generate any intermediate code like bytecode in java. The C and C++ generate directly Native Code which is specific to one platform or operating system. This Native code is known as object code (Machine Code ).
As we also know that Object Code (Machine Code) generation requires some Operating system files to be included which makes it platform dependent.
Whereas in Java we have intermediate code by the name of Byte Code (not a machine code). This can is understandable by JVM (Java virtual Machine) which converts it to the object code (machine Code) . That why in order to run Java code we need JVM installed on the device which makes java Platform independent.