Core Java & MySQL Mock Interview Q&A
Core Java:
1. What is the difference between JDK, JRE, and JVM?
Answer: JDK (Java Development Kit) provides tools to develop Java applications, JRE (Java
Runtime Environment) provides libraries to run Java applications, and JVM (Java Virtual Machine)
executes Java bytecode.
2. What are the key features of Java?
Answer: Platform independent, Object-oriented, Robust, Secure, Multithreaded, High performance,
Distributed, Dynamic.
3. What is the difference between == and equals() in Java?
Answer: == compares object references, while equals() compares the contents of the objects.
4. What are constructors in Java?
Answer: Constructors are special methods used to initialize objects. They have the same name as
the class and no return type.
5. What is method overloading and overriding?
Answer: Overloading means multiple methods with the same name but different parameters.
Overriding means redefining a method in a subclass with the same signature.
6. What is inheritance in Java?
Answer: Inheritance is when a class acquires the properties and behaviors of another class.
7. What is encapsulation?
Answer: Encapsulation is the concept of wrapping data and code together as a single unit, typically
using private variables and public methods.
8. What is polymorphism?
Answer: Polymorphism allows methods to do different things based on the object it is acting upon
(compile-time and runtime polymorphism).
9. What is an interface in Java?
Answer: An interface is a reference type with abstract methods, used to achieve abstraction and
multiple inheritance.
10. What are exceptions in Java?
Answer: Exceptions are events that disrupt the normal flow of the program. They are handled using
try-catch blocks.
MySQL:
11. What is MySQL?
Answer: MySQL is an open-source relational database management system.
12. What are the different types of joins in MySQL?
Answer: INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN (not directly supported in
MySQL but can be simulated).
13. What is a primary key?
Answer: A primary key uniquely identifies each record in a table and cannot be null.
14. What is a foreign key?
Answer: A foreign key is a field that uniquely identifies a row in another table, used to maintain
referential integrity.
15. What is the difference between WHERE and HAVING?
Answer: WHERE filters rows before grouping; HAVING filters groups after grouping.
16. What is normalization?
Answer: Normalization is the process of organizing data to reduce redundancy and improve
integrity.
17. What is a stored procedure?
Answer: A stored procedure is a prepared SQL code that can be saved and reused.
18. What is indexing?
Answer: Indexing improves the speed of data retrieval operations on a database table at the cost of
additional writes and storage.
19. What are transactions in MySQL?
Answer: A transaction is a sequence of operations performed as a single unit. It ensures ACID
properties.
20. What is the difference between DELETE and TRUNCATE?
Answer: DELETE removes specific rows and can be rolled back. TRUNCATE removes all rows and
cannot be rolled back.