0% found this document useful (0 votes)
37 views2 pages

What Are The Default Values Assigned To Variables and Instances in Java?

There are no default values assigned to variables in Java, but objects have default values depending on their type - references are null, numbers are 0, and booleans are false. Data encapsulation hides data attributes and behaviors within a class. The JIT compiler improves runtime performance by compiling parts of bytecode with similar functionality together, reducing compilation time for code to run.

Uploaded by

visitsdf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

What Are The Default Values Assigned To Variables and Instances in Java?

There are no default values assigned to variables in Java, but objects have default values depending on their type - references are null, numbers are 0, and booleans are false. Data encapsulation hides data attributes and behaviors within a class. The JIT compiler improves runtime performance by compiling parts of bytecode with similar functionality together, reducing compilation time for code to run.

Uploaded by

visitsdf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

What do you mean by data encapsulation?

 Data Encapsulation is an Object-Oriented Programming concept of hiding the data attributes


and their behaviours in a single unit.
 It helps developers to follow modularity while developing software by ensuring that each
object is independent of other objects by having its own methods, attributes, and
functionalities.
 It is used for the security of the private properties of an object and hence serves the purpose
of data hiding.

Tell us something about JIT compiler.

 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.

You might also like