- Java is a platform independent language
- Javac compiles the program to form a bytecode or .class file .
- JVM mush be on the device in OS for furthur execution of the byte code
- Simpicity
- Platform independent
- Interpreted: Java is intepreted as well as a compiler-based language.
- Robust Language: features like garbage collection,exception handling ,etc that make the language robust
- Object Oriented Language(OOPS)
- High Performance
- Dynamic: Supports dynamic loading of classes and interfaces
- Multithreaded: deal with multiple tasks at once by defining multiple threads
JVM is a java interpreter , reponsible for loading,verifying, and executing the bytecode created in Java.
Jit compiler is a part of JRE(JAVA RUNTIME ENVIRONMENT), used for better performance of java applications during runtime
-
Source code is compiled with javac to form bytecode
-
Bytecode is further passed on to JVM
-
JIT is a part of JVM, JIT is responsible for compiling bytecode into natice machine code at run time.
-
When a method (a block of code) is invoked (called) for the first time, the JIT compiler kicks in. It compiles the method into machine code, which is much faster to execute. This compilation step happens just in time, hence the name Just-In-Time compiler.
-
Class(Method) Area: Class Area is a memory in JVM that storeds information about classes and methods.
-
Heap : Objects are created or objects are stored. Used to Allocate memory to objects during run time.
-
Stack :Stores data and partial results
-
Program Counter Register: The PCR ensures that the JVM knows exactly where it is in the program and what instruction to execute next. This allows the JVM to run the program correctly and efficiently.
-
Native method stack : The Native Method Stack stores native methods (code written in languages like C or C++) used in a Java application, allowing the JVM to interact with the operating system, hardware, or external systems when needed.
ClassLoader is a part of JRE, during the execution of the bytecode or created .class file CLASSLOADER is responsible for dynamically loading the java classes and interfaces to JVM.Because of classloaders java run time system does not need to know about files and file system.
- Type of interpreter responsible for converting bytecode into machine-readable code.
- JVM itself is platform dependent but it interprets the bytecode which is the platform-independent reason why java is platform-independet
- An installation package that provides an environment to run the java program or application on any machine
- Java development kit which provides the environment to develop and execute java programs.
- JDK provdies two things
- Development tools to provide an envirnoment to develop you java programs
- JRE to execute java programs or applications
=====================================
C++ | Java | |
---|---|---|
Platform Dependence | Dependent | Independent |
C++ | Java | |
---|---|---|
Main Use Case | System Programming | Application Programming |
C++ | Java | |
---|---|---|
Hardware Interaction | Nearer to hardware | Not so interactive with hardware |
C++ | Java | |
---|---|---|
Global Scope | Supported | Not Supported |
Namespace Scope | Supported | Not Supported |
Functionality |
---|
Thread Support |
Documentation Comment |
Unsigned Right Shift (>>> ) |
Functionality |
---|
Goto |
Pointers |
Call by Reference |
Structures and Unions |
Multiple Inheritance |
Virtual Functions |
OOPS |
C++ | Java | |
---|---|---|
Object-Oriented Language | Yes | Yes |
Inheritance Hierarchy | Multiple roots | Single root (java.lang.Object) |
C++ | Java | |
---|---|---|
Inheritance Tree | Creates a new tree | Uses a single inheritance tree |
- public : Tells who can access the element or the method and what is the limit.
- static :
- Primitive Data type : boolean , char , int , short , byte , long , float and double
Primitive means : basic building blocks of data manipulation
-
Non primitive means : memory address of a variable will be stored,because the reference types won't stores the variable value directly in memory.
-
Non - Primitive Data type :String , array
- Variable : Data cointainer that save the data values during java program execution
Key note , Java programs are first compiled to an intermediate form , then interpreted by the interpreter.
// Sigle line comments /* Multi line comments */
- Arithemetic Operator
This operations includes + , - , * , / and %
- Unary Operator
Java unary operators are he types that need only one operand to perform any operation like increment , decrement and negation etc.
- Unary minus(-)
Converts a positive value to a negative value or vice versa
- Not (!)
Converts true to false or vice versa
-
Increment (++) & Decrement (--)
Post Increment (num++) and Pre Increment (++num) & Post Decrement (num--) and Post Decrement (--num)
-
Bitwise Complement(~)
Returns on's complement representation of the input value or operand
- Assignment Operator
= , += , -= , *= , /= , %=
- Relational Operators
== , != , > , < ,<= , >=
- Logical Operators
AND operator (&&) OR operator (||) NOT operator (!)
- Ternary Operator
variable = expression1 ? expression2 : expression3
- Bitwise Operators
- Bitwise OR(|)
this is binary operator, denoted by "|".
eg: if either of the bits is 1, it gives 1, else it shows 0.
- Bitwise And(&)
this is binary operator. if both bits are 1 , then it gives 1 , else shoes 0
- Bitwise XOR(^)
this is binary operator if corresponstings bits are different , then it gives 1 else gives 0
- Bitwise Complement (~)
this is unary operator makes 1 to 0 and 0 to 1