### **Top 100 Java, Selenium, TestNG, Maven Interview Questions with Detailed Answers**
---
### **Java Questions**
#### **Basics**
1. **What are the key features of Java?**
- Object-Oriented: Supports encapsulation, inheritance, and polymorphism.
- Platform-Independent: Java bytecode runs on any JVM.
- Secure: Features like bytecode verification, no explicit pointers.
- Multithreaded: Supports concurrent execution of two or more threads.
- Robust: Automatic garbage collection, exception handling.
2. **Explain the concept of OOPs in Java.**
- Encapsulation: Wrapping data and methods into a single unit.
- Inheritance: Acquiring properties from a parent class.
- Polymorphism: Ability to take multiple forms, achieved via method overloading/overriding.
- Abstraction: Hiding implementation details using abstract classes or interfaces.
3. **What is the difference between `ArrayList` and `LinkedList`?**
- **ArrayList**: Uses a dynamic array; faster for accessing elements.
- **LinkedList**: Uses doubly linked list; faster for insertion/deletion.
4. **What are `HashMap` and `HashSet`, and how do they differ?**
- `HashMap`: Stores key-value pairs; allows one null key and multiple null values.
- `HashSet`: Stores only unique elements; backed by a `HashMap` internally.
5. **What is the difference between `final`, `finally`, and `finalize`?**
- `final`: Keyword to define constants or restrict inheritance/overriding.
- `finally`: Block to execute code regardless of exception occurrence.
- `finalize`: Method called by garbage collector before object deletion.
6. **What is the difference between `==` and `.equals()` in Java?**
- `==`: Compares references.
- `.equals()`: Compares content.
7. **Explain the use of `static` and `this` keywords.**
- `static`: For class-level methods/variables.
- `this`: Refers to the current instance of a class.
8. **What is a constructor, and how is it different from a method?**
- Constructor: Initializes an object; no return type.
- Method: Performs operations; has a return type.
9. **What are checked and unchecked exceptions in Java?**
- **Checked**: Caught during compile-time (e.g., IOException).
- **Unchecked**: Caught during runtime (e.g., NullPointerException).
10. **What are `String`, `StringBuilder`, and `StringBuffer`?**
- **String**: Immutable sequence of characters.
- **StringBuilder**: Mutable; not thread-safe.
- **StringBuffer**: Mutable; thread-safe.
#### **Advanced Concepts**
11. **Explain the concept of polymorphism with examples.**
- Compile-time (method overloading) and runtime (method overriding).
- Example:
```java
class Shape {
void draw() { System.out.println("Drawing Shape"); }
class Circle extends Shape {
void draw() { System.out.println("Drawing Circle"); }
Shape obj = new Circle();
obj.draw(); // Output: Drawing Circle
```
12. **What is method overloading and method overriding? How do they differ?**
- **Overloading**: Same method name, different parameter list (compile-time).
- **Overriding**: Same method name and parameters, but redefined in a subclass (runtime).
...
*(Complete the remaining questions and answers as listed in the document)*