Skip to content

Latest commit

 

History

History
86 lines (71 loc) · 3.23 KB

java-basic-interview-questions.md

File metadata and controls

86 lines (71 loc) · 3.23 KB

Back to Home

The Overview of Java Basic Interview Questions

Here are some Java basic interview questions and their answers:

List of Content

1. What is Java?

Java is a high-level, object-oriented programming language that was designed to be platform-independent and easily portable.

2. What is the difference between JDK, JRE, and JVM?

JDK stands for Java Development Kit and includes tools for developing and compiling Java code. JRE stands for Java Runtime Environment and is used to run Java applications. JVM stands for Java Virtual Machine and is responsible for executing Java bytecode.

3. What are the main features of Java?

Some main features of Java include platform independence, object-oriented programming, multithreading, automatic garbage collection, and built-in exception handling.

4. What is an Object in Java?

An object is an instance of a class that has its own set of properties and methods.

5. What is a Class in Java?

A class is a blueprint or template for creating objects that defines the properties and methods of the object.

6. What is Inheritance in Java?

Inheritance is a feature of object-oriented programming that allows a new class to be based on an existing class, inheriting its properties and methods.

7. What is Polymorphism in Java?

Polymorphism is a feature of object-oriented programming that allows objects of different classes to be treated as if they are of the same type.

8. What is Encapsulation in Java?

Encapsulation is a feature of object-oriented programming that involves hiding the implementation details of an object and providing access to its properties and methods only through a public interface.

9. What is Abstraction in Java?

Abstraction is a feature of object-oriented programming that involves defining the essential characteristics of an object and ignoring the non-essential details.

10. What is the difference between an Abstract Class and an Interface in Java?

An abstract class can have both concrete and abstract methods, while an interface can only have abstract methods. Additionally, a class can only extend one abstract class, but can implement multiple interfaces.

11. What is the difference between a Compiler and an Interpreter in Java?

A compiler translates source code into machine code, while an interpreter executes code directly.

12. What is the difference between a String, StringBuilder, and StringBuffer in Java?

A String is an immutable sequence of characters, while a StringBuilder and StringBuffer are mutable sequences of characters. StringBuilder is not thread-safe, while StringBuffer is thread-safe.

13. What is a Package in Java?

A package is a collection of related classes and interfaces that provide a namespace for organizing code and avoiding naming conflicts.

14. What is a Constructor in Java?

A constructor is a special method used to initialize an object when it is created.

15. What is the difference between an instance variable and a static variable in Java?

An instance variable is associated with a specific instance of a class and has a different value for each instance, while a static variable is associated with the class itself and has the same value for all instances of the class.