What Are The Default Values Assigned To Variables and Instances in Java?
What Are The Default Values Assigned To Variables and Instances in Java?
There are no default values assigned to the variables in java. We need to initialize the value
before using it. Otherwise, it will throw a compilation error of (Variable might not be
initialized).
But for instance, if we create the object, then the default value will be initialized by the
default constructor depending on the data type.
If it is a reference, then it will be assigned to null.
If it is numeric, then it will assign to 0.
If it is a boolean, then it will be assigned to false. Etc.
JIT stands for Just-In-Time and it is used for improving the performance during run time. It
does the task of compiling parts of byte code having similar functionality at the same time
thereby reducing the amount of compilation time for the code to run.
The compiler is nothing but a translator of source code to machine-executable code. But what
is special about the JIT compiler? Let us see how it works:
o First, the Java source code (.java) conversion to byte code (.class) occurs with the help of the
javac compiler.
o Then, the .class files are loaded at run time by JVM and with the help of an interpreter, these
are converted to machine understandable code.
o JIT compiler is a part of JVM. When the JIT compiler is enabled, the JVM analyzes the
method calls in the .class files and compiles them to get more efficient and native code. It
also ensures that the prioritized method calls are optimized.
o Once the above step is done, the JVM executes the optimized code directly instead of
interpreting the code again. This increases the performance and speed of the execution.