Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Java Interview Questions

(Top 100+ Questions and Answers on


Java)
Q.1: What is Java?
Java is a high-level, object-oriented, multithreaded, portable,
and platform-independent programming language. It was
originally designed by James Gosling at Sun Microsystems in June
1991. In 1995, it was released as a core component of Sun
Microsystems.
Later, Sun Microsystems was acquired by Oracle and hence Java
was henceforth developed by Oracle. Currently, Java is one of
the most popular programming languages in the world. It is also
considered as the platform because it has its own JRE and API.
Q.2: What are the main features of
Java?
• Simple
• Object-oriented
• Distributed
• Robust
• Secure
• System Independent
• Portable
• Multithreaded
Q.3: Why pointers are eliminated from
Java?
Pointers are eliminated from Java because:
• Pointers lead to confusion for a program.
• Pointers may crash a program easily. For example, if two pointers
are added, the program crashes immediately. The same thing can
also happen when we forget to free the memory allotted to a
variable and reallot it to another variable.
• Pointers break security. By using pointers, harmful programs such
as viruses and other hacking programs can be developed.
Q.4: What is the class?
There may be some scenarios where some objects
may have similar properties and functions. Such
objects belong to the same category which is
known as a 'class'. For example, Jacob, James,
Smith, etc. belong to a person class. They have the
same properties and actions.
Q.5: Define an object in Java. How an
object is created in Java?
An object denotes an instance of a class. It is a real-
world entity that contains state and behavior. An
object basically consists of the following three
characteristics:
• State
• Behavior
• Identity
Q.6: What is the difference between an
executable file and a class file?
An executable file (.exe) contains machine
language instructions for the microprocessor and
is system dependent. Besides, the class file
contains byte code instructions for the JVM and is
system independent.
Q.7: What is the BYTE code?
The BYTE code is an intermediate-level code that is
interpreted by the JVM. It is not directly executable on
the machine. A BYTE code is a mediator code between
Java program and machine code of operating system (OS)
and is available in ‘.class’ file. A ‘.class’ file is generated
when the Java program or application gets compiled.
BYTE code is the same for any OS but machine code
differs on each OS.
Q.8: What is JVM?
The JVM (Java Virtual Machine) is an abstract
machine designed to be implemented on the top
of existing processors. It hides the underlying
operating system (OS) from Java applications. It is
actually the heart of the entire Java program
execution process.
Q.9: What is JRE?
JRE stands for the 'Java Runtime Environment'. It
is a platform consisting of Java virtual machines,
Java libraries, and all other components required
to run Java applications and applets.
Q.10: What is the Java compiler?
A Java compiler is a program that converts Java
source code to Java byte code.
A basic Java compiler is already included in JDK
(Java Development Kit). The Java compiler is
known as 'javac'.
Read More at:
www.tutorialsmate.com

You might also like