Java Developer Internship - Interview Questions and Answers
Q: What is Java?
A: Java is a high-level, object-oriented programming language developed by Sun Microsystems. It is
platform-independent due to the Java Virtual Machine (JVM), which allows Java code to run on any
device.
Q: What are the main features of Java?
A: - Platform Independent
- Object-Oriented
- Robust and Secure
- Multithreaded
- High Performance
- Dynamic and Portable
Q: What is the difference between JDK, JRE, and JVM?
A: - JDK (Java Development Kit): A full software development kit including JRE and development
tools like compilers.
- JRE (Java Runtime Environment): Provides runtime environment and contains JVM and libraries.
- JVM (Java Virtual Machine): Executes Java bytecode and provides platform independence.
Q: What is the difference between == and .equals() in Java?
A: - == compares object references (memory location).
- .equals() compares the actual content of objects (like string values).
Q: What is a constructor in Java?
A: A constructor is a special method used to initialize objects. It has the same name as the class
and no return type.
Q: What is the difference between overloading and overriding?
A: - Overloading: Same method name, different parameters (within the same class).
- Overriding: Same method name and parameters in a subclass to provide specific behavior.
Q: What is inheritance in Java?
A: Inheritance is a mechanism where one class (child) inherits properties and behavior from another
class (parent), promoting code reusability.
Q: What is an interface?
A: An interface in Java is a collection of abstract methods. It is used to achieve abstraction and
multiple inheritance.
Q: What are access modifiers in Java?
A: Access modifiers define the scope of classes, methods, and variables.
- private
- default
- protected
- public
Q: Can you explain exception handling in Java?
A: Exception handling manages runtime errors using:
- try: code block to monitor
- catch: handles exceptions
- finally: executes code regardless of exception
- throw and throws: used to manually throw exceptions