How java is platform independent?

Answer Posted / steve

Java was designed to not only be cross-platform in source
form like C, but also in compiled binary form. Since this is
frankly impossible across processor architectures Java is
compiled to an intermediate form called byte-code. A Java
program never really executes natively on the host machine.
Rather a special native program called the Java interpreter
reads the byte code and executes the corresponding native
machine instructions. Thus to port Java programs to a new
platform all that is needed is to port the interpreter and
some of the library routines. Even the compiler is written
in Java. The byte codes are precisely defined, and remain
the same on all platforms.

The second important part of making Java cross-platform is
the elimination of undefined or architecture dependent
constructs. Integers are always four bytes long, and
floating point variables follow the IEEE 754 standard for
computer arithmetic exactly. You don't have to worry that
the meaning of an integer is going to change if you move
from a Pentium to a PowerPC. In Java everything is guaranteed.

However the virtual machine itself and some parts of the
class library must be written in native code. These are not
always as easy or as quick to port as pure Java programs.

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What about anonymous inner classes in java?

781


Is array a class?

713


What is flag in python?

802


Difference between arraylist and hashset in java?

782


What is size of int in java?

801


What is the major advantage of external iteration over internal iteration?

825


What is the difference between method overriding and overloading?

823


How many bytes is double?

740


What is sortedset in java?

781


Why inputstreamreader is used in java?

769


What is the reflection?

777


What does || || mean in math?

701


What is a cup of java?

794


Can inner class extend any class?

807


How to sort a collection of custom Objects in Java?

825