ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Java Related >> Java J2EE >> Core Java
 
 


 

 
 Core Java interview questions  Core Java Interview Questions (1720)
 Advanced Java interview questions  Advanced Java Interview Questions (331)
 Swing interview questions  Swing Interview Questions (43)
 EJB interview questions  EJB Interview Questions (134)
 Servlets interview questions  Servlets Interview Questions (255)
 Struts interview questions  Struts Interview Questions (195)
 JDBC interview questions  JDBC Interview Questions (187)
 JMS interview questions  JMS Interview Questions (9)
 SunOne interview questions  SunOne Interview Questions (3)
 J2EE interview questions  J2EE Interview Questions (71)
 Weblogic interview questions  Weblogic Interview Questions (145)
 Websphere interview questions  Websphere Interview Questions (14)
 Java Networking interview questions  Java Networking Interview Questions (20)
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions (87)
Question
Why Java is a platform independent language?
 Question Submitted By :: Balakrishna
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Why Java is a platform independent language?
Answer
# 1
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 ?    104 Yes 26 No
Rani
 
  Re: Why Java is a platform independent language?
Answer
# 2
The compiler converts source code file into bytecode files. These codes are machine independent and can be run on any machine. Java interpreter reads the bytecode files and translates them into machine code for the specific machine on which the Java program in running. 
Is This Answer Correct ?    143 Yes 5 No
Nikhlesh Gupta Datia(m.p.)
 
 
 
  Re: Why Java is a platform independent language?
Answer
# 3
One of the key reasons Java technology is useful in a
networked environment is that Java makes it possible to
create binary executables that will run unchanged on
multiple platforms. This is important in a networked
environment because networks usually interconnect many
different kinds of computers and devices. In a typical
enterprise environment, for example, a network might
connect Macintoshes in the art department, UNIX
workstations in engineering, and PCs running Windows
everywhere else. Although this arrangement enables various
kinds of computers and devices within the company to share
data, it requires a great deal of administration. Such a
network presents a system administrator with the task of
keeping different platform-specific editions of programs up
to date on many different kinds of computers. Programs that
can run without change on any networked computer,
regardless of the computer's type, make the system
administrator's job simpler, especially if those programs
can actually be delivered across the network.

 
Is This Answer Correct ?    20 Yes 6 No
Guest
 
  Re: Why Java is a platform independent language?
Answer
# 4
platform independent means,the java compiled program can be
run on any operating system.because when you compile a
program you will get a class file which contains byte code
which is specific to java. that byte code can understand by
jvms (java virtual machines).for different operating
systems different jvms will be there.so the jvm will
convert the byte code into machine understandable code.so
as the jvm is different for different operating systems no
need to worry much,that will take care of explaining to the
os.ok.
 
Is This Answer Correct ?    85 Yes 5 No
Prapanch
 
  Re: Why Java is a platform independent language?
Answer
# 5
Platform independent is nothing but write-once
Run-Anywhere.It means program can run on any Operating
System(OS).

compiler Interpreter
Java source code------->M/C code------->Linux or windows
javac JVM
Fig.

When you compile a source code by using javac compiler you
will get .class file which contains byte code.
that byte code can understand by JVM(Java Virtual Machine).
so, the JVM is different for different OS(operating system).
after that the JVM will convert the byte code(by using
interpreter) into machine understandable code i.e 1's & 0's.
Java is compiler as well as Interpreter Programming Language.
 
Is This Answer Correct ?    0 Yes 0 No
Shital Mhetre
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
why the abstract class has default constructor?   2
What is adapter class?   12
suppose in a class there is a code like this: { Set hs=new Hashset(); hs.add(new Emp("kathy",1000)); hs.add(new Emp("kathy",2000)); } how can u avoid the above code in your class as set won't allow duplicate objects?   3
Can you declare a static variable in a method?   7
public class Base { public void myMethod(int a,intb) {} } // Uses myMethod and then hides it. public class DerivedOne extends Base { private void myMethod(int a,int b); } will this compile or not .yes or no. why   2
In how many ways we can the thread? in java   3
why there are multiple catches for a try block.don't tell me that there can be multiple exception of a code segment that's why.tell me the real fact behind this.   4
can anyone explain me the concept of autoboxing?   3
diffrence b\w println() and printf() NIIT 7
What is the functionality of Webserver?   2
what is main purpose of abstract class?   7
Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what the name should i provide to the file ,in what file name should i run the program? Ple Explain DNS 9
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com