Features of Java
Simple: Java is very simple and easy to learn. We don’t need prior
knowledge to learn java.
Platform Independent: If we write a java program it gets converted to byte
code/ class file, this can run on any OS like windows, MacOS, Linux, etc.
ByteCode/ Windows
Java Program Class_file Mac
Linux
Object oriented: This implements everything in java is an object of class.
Java supports 4 types of OOP principal Abstraction, Inheritance,
Encapsulation, Polymorphism.
Architecture Neutral: Java program never connects with system
specification, so changes made to OS or system resources will never force
any changes to the java programs.
Secure: Unlike C/C++, java doesn’t use any pointers except (which stores
the real address) which makes java more secure as it doesn’t give real
address to the user (converted to String). It also uses byte code verifier
which checks the byte code before running a program.
Multithreading: Thread is sub-process executing multiple threads at some
time is called multithreading which helps to achieve parallelism which
increases the performance.
Execution Phases
Java Program
Simplifier
Class JIT Interpreter
loader
ByteCode/
Class_file Byte code
verifier
Runtime
Description of Diagram
When we write a java program (we ca write program in any editor). We
should call compiler here which checks syntax and semantics error with the help
of command “javac provide_file_name.java”. If compilation is success, we get
byte code or class file which is with the extension “.class”. This process happens
at compile time.
Once we get byte-code we have to call JVM (Java Virtual Machine) with the
help of command “java class_name”. Initially JVM loads all the classes which are
required to execute this program with the help of class loaders. Now byte code
verifier checks the validity and integrity of the byte code before run. Now JIT
(Just in Time Compiler) converts redundant lines of code (similar lines of code)
to one line reducing the length of the code. Interpreter converts every line of
the code to binary line by line.