Why Java is a platform independent language?

Answer Posted / rani

Java solves the problem of platform-independence by using
byte code. The Java compiler does not produce native
executable code for a particular machine like a C compiler
would. Instead it produces a special format called byte
code. Java byte code written in hexadecimal, byte by byte,
looks like this:

CA FE BA BE 00 03 00 2D 00 3E 08 00 3B 08 00 01 08 00 20 08

This looks a lot like machine language, but unlike machine
language Java byte code is exactly the same on every
platform. This byte code fragment means the same thing on a
Solaris workstation as it does on a Macintosh PowerBook.
Java programs that have been compiled into byte code still
need an interpreter to execute them on any given platform.
The interpreter reads the byte code and translates it into
the native language of the host machine on the fly. The most
common such interpreter is Sun's program java (with a little
j). Since the byte code is completely platform independent,
only the interpreter and a few native libraries need to be
ported to get Java to run on a new computer or operating
system. The rest of the runtime environment including the
compiler and most of the class libraries are written in Java.

All these pieces, the javac compiler, the java interpreter,
the Java programming language, and more are collectively
referred to as Java.

Is This Answer Correct ?    118 Yes 34 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about java sdk?

578


Explain restrictions on using enum?

631


how come we know the object is no more used in the class?

5425


Can we rethrow the same exception from catch handler?

561


How will you load a specific locale?

536






Which data type is a class in java?

571


Why chararray() is preferred over string to store the password?

526


What is the difference between scrollbar and scrollpane?

607


Can we override private constructor in java?

507


What data type is true or false?

573


What is a generic type?

561


Explain inheritance in java?

555


What is linked hashmap and its features?

544


Can we cast any other type to boolean type with type casting?

539


What is string pooling concept?

554