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

Java Interview Questions

Uploaded by

Suresh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Java Interview Questions

Uploaded by

Suresh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1. Why Java is not called pure object oriented programming?

Java is not a "PURE" Object Oriented Language , because it uses primitive data types such as
(int,float,char...etc). The developers of java could have made these primitive data types as
objects(like String... etc), but the primitive data types such as int float... are more faster than objects!

2. Why is Java Not Completely Platform Independent?

Java is not completely Platform Independent. The javac compiler first compiles the High-Level
program code written by the programmer, and byte code is formed. This byte code is platform-
independent but requires a Just In Time (JIT) interpreter/compiler.

3. What is the JRE (Java Runtime Environment)?

The Java Runtime Environment, or JRE, is a software layer that runs on top of a
computer’s operating system software and provides the class libraries and other
resources that a specific Java program needs to run.

4. What is JVM?
JVM(Java Virtual Machine) acts as a run-time engine to run Java applications. JVM is the one that actually calls
the main method present in a java code. JVM is a part of JRE(Java Runtime Environment).

Java applications are called WORA (Write Once Run Anywhere). This means a programmer can develop Java
code on one system and can expect it to run on any other Java-enabled system without any adjustment. This is
all possible because of JVM.

When we compile a .java file, .class files(contains byte-code) with the same class names present in .java file are
generated by the Java compiler. This .class file goes into various steps when we run it. These steps together
describe the whole JVM.

5. Difference between Heap and Stack Memory in java. And how java utilizes this .

Stack memory is the portion of memory that was assigned to every


individual program. And it was fixed. On the other hand, Heap memory is
the portion that was not allocated to the java program but it will be
available for use by the java program when it is required, mostly during
the runtime of the program.

Java Utilizes this memory as -

 When we write a java program then all the variables, methods, etc
are stored in the stack memory.
 And when we create any object in the java program then that
object was created in the heap memory. And it was referenced
from the stack memory.
6. How is Java different from C++?

C++ is only a compiled language, whereas Java is compiled as well as an


interpreted language.

Java programs are machine-independent whereas a c++ program can run


only in the machine in which it is compiled.

C++ allows users to use pointers in the program. Whereas java doesn’t
allow it. Java internally uses pointers.

C++ supports the concept of Multiple inheritances whereas Java doesn't


support this. And it is due to avoiding the complexity of name ambiguity
that causes the diamond problem.

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

8.

You might also like