🚀 Coding Interview Questions with Answers (Part 17)
1️⃣6️⃣1️⃣ What is an Aggregate Function? Answer: An aggregate function performs calculations on a group of rows and returns a single result. Common Aggregate Functions: • "COUNT()" – Counts the number of rows. • "SUM()" – Calculates the total of a numeric column. • "AVG()" – Returns the average value. • "MIN()" – Returns the smallest value. • "MAX()" – Returns the largest value.
Example: SELECT AVG(Salary) FROM Employees;
1️⃣6️⃣2️⃣ What is the GROUP BY Clause? Answer: The "GROUP BY" clause is used to group rows that have the same values in one or more columns. It is commonly used with aggregate functions to summarize data.
Example: SELECT Department, COUNT(*) FROM Employees GROUP BY Department;
Applications: • Sales reports • Employee statistics • Business analytics
1️⃣6️⃣3️⃣ What is the HAVING Clause? Answer: The "HAVING" clause is used to filter grouped records after the "GROUP BY" operation.
Difference: • "WHERE" filters individual rows before grouping. • "HAVING" filters groups after grouping.
Example: SELECT Department, AVG(Salary) FROM Employees GROUP BY Department HAVING AVG(Salary) > 50000;
1️⃣6️⃣4️⃣ What is the Difference Between DELETE, DROP, and TRUNCATE?
Answer: DELETE • Removes selected rows. • Can use a "WHERE" clause. • Can be rolled back (depending on the transaction).
TRUNCATE • Removes all rows from a table. • Cannot use a "WHERE" clause. • Faster than "DELETE". • Keeps the table structure.
DROP • Removes the entire table, including its structure and data. • The table no longer exists after execution.
1️⃣6️⃣5️⃣ What is Database Optimization? Answer: Database optimization is the process of improving database performance to make queries execute faster and use fewer resources.
Techniques: • Creating indexes • Writing efficient SQL queries • Normalization and denormalization • Query optimization • Partitioning large tables
1️⃣6️⃣6️⃣ What is an Operating System? Answer: An Operating System (OS) is system software that manages computer hardware and software resources while providing services for application programs.
Examples: • Windows • Linux • macOS • Android • iOS
Functions: • Memory management • Process management • File management • Device management • Security
1️⃣6️⃣7️⃣ What is a Process? Answer: A process is a program that is currently being executed. Each process has its own memory space, resources, and execution state.
Characteristics: • Independent execution • Own memory allocation • Managed by the operating system Example: Running a web browser or text editor.
1️⃣6️⃣8️⃣ What is a Thread? Answer: A thread is the smallest unit of execution within a process. Multiple threads within the same process share memory and resources.
Advantages: • Faster execution • Better responsiveness • Efficient resource utilization
Example: A web browser downloading a file while allowing you to browse other pages.
1️⃣6️⃣9️⃣ What is the Difference Between a Process and a Thread? Answer: Process • Independent execution unit. • Has its own memory space. • Higher resource consumption. • Communication between processes is slower.
Thread • Runs within a process. • Shares memory with other threads. • Lower resource consumption. • Faster communication between threads.
1️⃣7️⃣0️⃣ What is CPU Scheduling? Answer: CPU Scheduling is the process of selecting which process or thread should use the CPU next. Common Scheduling Algorithms: • First Come First Serve (FCFS) • Shortest Job First (SJF) • Round Robin (RR) • Priority Scheduling • Multilevel Queue Scheduling
Objectives: • Maximize CPU utilization. • Minimize waiting time. • Improve system responsiveness. • Increase throughput.
🔥 Double Tap ❤️ For Part-18