Basic Java Questions and Answers
Q1: What is Java?
A1: Java is a high-level, class-based, object-oriented programming language that is designed to
have as few implementation dependencies as possible.
Q2: What is JVM?
A2: JVM stands for Java Virtual Machine, which is an abstract machine that enables your computer
to run a Java program. When you run a Java program, JVM is responsible for converting bytecode
into machine-specific code.
Q3: What is JRE?
A3: JRE stands for Java Runtime Environment. It is a set of software tools used for developing Java
applications. It includes the JVM, core libraries, and other components to run applications written in
Java.
Q4: What is JDK?
A4: JDK stands for Java Development Kit. It is a full-featured software development kit for Java,
including JRE, an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation
generator (Javadoc), and other tools needed for Java development.
Q5: What is a class in Java?
A5: A class in Java is a blueprint from which individual objects are created. It can contain fields,
methods, constructors, and blocks.
Q6: What is an object in Java?
A6: An object is a real-world entity that has state and behavior. In Java, an object is an instance of a
class.
Q7: What are the main features of Java?
A7: The main features of Java include Object-Oriented, Platform Independent, Simple, Secure,
Architecture-neutral, Portable, Robust, Multithreaded, High Performance, Distributed, and Dynamic.
Q8: What is inheritance in Java?
A8: Inheritance is a mechanism wherein a new class is derived from an existing class. The derived
class (child class) inherits the properties and behavior of the existing class (parent class).
Q9: What is polymorphism in Java?
A9: Polymorphism in Java is the ability of a method to do different things based on the object it is
acting upon. It can be achieved by method overloading and method overriding.
Q10: What is encapsulation in Java?
A10: Encapsulation is a principle of wrapping the data (variables) and the code acting on the data
(methods) together as a single unit. It helps to protect the data from outside interference and
misuse.