SQL, Database, and OOPs Interview Questions for Freshers
1. What is SQL?
SQL (Structured Query Language) is a standard programming language for managing and
manipulating relational databases. It is used to perform tasks such as querying data, updating
records, and managing database structures.
2. What are the different types of SQL commands?
SQL commands are classified into DDL (Data Definition Language), DML (Data Manipulation
Language), DCL (Data Control Language), and TCL (Transaction Control Language). Examples
include SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, etc.
3. What is a primary key?
A primary key is a column or a set of columns in a table that uniquely identifies each row in that
table. It must contain unique values and cannot have NULL values.
4. What is a foreign key?
A foreign key is a column or set of columns in one table that refers to the primary key in another
table. It is used to establish a relationship between the two tables.
5. What is normalization?
Normalization is the process of organizing data in a database to reduce redundancy and improve
data integrity. It involves dividing a database into multiple related tables.
6. What are joins in SQL?
Joins are used in SQL to combine rows from two or more tables based on a related column. Types
include INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN, and CROSS JOIN.
7. What is the difference between WHERE and HAVING clauses?
WHERE is used to filter rows before grouping, while HAVING is used to filter groups after
aggregation.
8. What is an index in SQL?
An index is a database object that improves the speed of data retrieval operations. It works like an
index in a book, pointing to the location of data.
9. What is a view in SQL?
A view is a virtual table that is based on the result set of an SQL query. It does not store data
physically but provides a way to simplify complex queries.
10. What is the difference between DELETE and TRUNCATE?
DELETE removes rows one at a time and can be rolled back. TRUNCATE removes all rows from a
table instantly and cannot be rolled back.
11. What is a database?
A database is an organized collection of data stored electronically that allows for efficient data
retrieval, management, and updating.
12. What is a DBMS?
DBMS (Database Management System) is software that interacts with users and applications to
define, manipulate, and manage databases.
13. What is a relational database?
A relational database organizes data into tables (relations) with rows and columns. Relationships
between tables are established using keys.
14. What is ACID in databases?
ACID stands for Atomicity, Consistency, Isolation, and Durability. It is a set of properties that
ensures reliable database transactions.
15. What is denormalization?
Denormalization is the process of combining tables to reduce the complexity of queries and improve
read performance, often at the expense of data redundancy.
16. What is Object-Oriented Programming (OOP)?
OOP is a programming paradigm based on the concept of objects, which contain data (attributes)
and methods (functions).
17. What are the four principles of OOP?
The four principles of OOP are Encapsulation, Abstraction, Inheritance, and Polymorphism.
18. What is encapsulation?
Encapsulation is the process of wrapping data and methods into a single unit, restricting direct
access to some components.
19. What is inheritance?
Inheritance is a mechanism where one class (child) derives properties and behavior from another
class (parent).
20. What is polymorphism?
Polymorphism allows objects to be treated as instances of their parent class, enabling a single
interface to represent different types.