1.
Core Java
Q: What are the four pillars of OOP?
A: Encapsulation, Inheritance, Polymorphism, and Abstraction.
Q: Difference between class and object?
A: Class is a blueprint; Object is an instance of a class.
Q: What is method overloading vs overriding?
A: Overloading: same name, different parameters. Overriding: same method redefined in subclass.
Q: Can you override a static method?
A: No, static methods belong to the class.
Q: Difference between abstract class and interface?
A: Abstract class can have some method code; interface has only method declarations (before
Java 8).
2. Collections Framework
Q: Difference between List, Set, and Map?
A: List allows duplicates, Set doesn't, Map stores key-value pairs.
Q: Difference between ArrayList and LinkedList?
A: ArrayList is fast for access; LinkedList is fast for insert/delete.
Q: What happens if you insert a duplicate key in HashMap?
A: It replaces the old value.
3. Spring Boot Basics
Q: What is Spring Boot?
A: Spring Boot simplifies Spring setup using auto-configuration and starter dependencies.
Q: What is Dependency Injection?
A: Spring automatically creates and injects required objects using @Autowired.
Q: What is @RestController?
A: Used to create REST APIs that return JSON or XML.
Q: What is @Service?
A: Marks a class as a service that contains business logic.
Q: What is @Autowired?
A: Used to inject a bean automatically where needed.
4. JPA / Hibernate
Q: What is JPA?
A: Java Persistence API, used for ORM to connect Java objects with database tables.
Q: What does @Entity mean?
A: Marks a class as a database table.
Q: What is @Id and @GeneratedValue?
A: Defines primary key and auto-increment behavior.
Q: What is OneToMany?
A: It represents one entity related to many others (e.g., one author → many books).
5. REST API
Q: What is REST API?
A: It allows communication between client and server using HTTP methods.
Q: Difference between GET, POST, PUT, DELETE?
A: GET: Read, POST: Create, PUT: Update, DELETE: Delete data.
Q: What is @RequestBody?
A: It maps JSON data from request body to a Java object.
Q: What is ResponseEntity?
A: Used to send HTTP status and response body together.
6. SQL Basics
Q: Difference between INNER JOIN and LEFT JOIN?
A: INNER JOIN shows matching rows; LEFT JOIN shows all from left table.
Q: What is primary key vs foreign key?
A: Primary key uniquely identifies a record; foreign key links to another table.
Q: Difference between DELETE, TRUNCATE, DROP?
A: DELETE removes rows, TRUNCATE removes all rows, DROP removes table.