0% found this document useful (0 votes)
15 views

Is Java A Compiled Language or An Interpreted One

Java code is first compiled to bytecode, then interpreted and executed on the target platform. The Java compiler compiles code to portable bytecode, while the Java interpreter converts bytecode to machine code for execution. With just-in-time compilation, frequently used code may be compiled directly to machine code for improved performance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Is Java A Compiled Language or An Interpreted One

Java code is first compiled to bytecode, then interpreted and executed on the target platform. The Java compiler compiles code to portable bytecode, while the Java interpreter converts bytecode to machine code for execution. With just-in-time compilation, frequently used code may be compiled directly to machine code for improved performance.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#Interviewer: Is Java a compiled language or an interpreted one?

Both. Yes, Java is both compiled as well as interpreted language. This is what
makes it platform-independent. Java Code >> Compile (javac) >> Bytecode (portable
code) >> Interpret (platform specific) >> Machine Code >> Execute.

Normal:

1. Java Compiler (javac) compiles Java code to Bytecode (which is platform-


independent).
2. Java Interpreter (java) interprets this bytecode (line-by-line) & convert it to
Machine language.
3. Execute.

Exception: JIT (Just In Time) Compiler

1. JVM maintains the count for no of times a function is executed.


2. If it exceeds the limit then JIT directly compiles the Java code into Machine
language. No Interpretation.

In General,

• Compile: Source code >> Optimized Object Code (can be machine code or other
optimized code)
• Interpret: Source Code >> Machine Code (to be executed)

You might also like