SQL Basic Level Interview Questions
1. What is SQL?
Answer: SQL (Structured Query Language) is a language designed to manage and
manipulate data in relational database management systems.
2. What are the basic SQL commands?
Answer: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, TRUNCATE.
3. What is the difference between INNER JOIN and LEFT JOIN?
Answer: INNER JOIN returns only the rows that have a match in both tables, while
LEFT JOIN returns all the rows from the left table and the matched rows from the
right table.
4. How do you filter data in SQL?
Answer: Using the WHERE clause.
5. What is a primary key?
Answer: A primary key is a column or set of columns that uniquely identifies each
row in a table.
6. What is a foreign key?
Answer: A foreign key is a column or set of columns that references the primary
key of another table.
7. How do you sort data in SQL?
Answer: Using the ORDER BY clause.
8. What is a subquery?
Answer: A subquery is a query nested inside another query.
9. How do you group data in SQL?
Answer: Using the GROUP BY clause.
10. What is an index in SQL?
Answer: An index is a data structure that improves the speed of data retrieval.
11. What is the difference between UNION and UNION ALL?
Answer: UNION removes duplicate rows, while UNION ALL returns all rows, including
duplicates.
12. How do you limit the number of rows returned in SQL?
Answer: Using the LIMIT clause.
13. What is a view in SQL?
Answer: A view is a virtual table based on the result of a SELECT statement.
14. How do you create a table in SQL?
Answer: Using the CREATE TABLE statement.
15. What is a stored procedure in SQL?
Answer: A stored procedure is a set of SQL statements that can be executed with a
single command.
16. How do you update data in SQL?
Answer: Using the UPDATE statement.
17. What is a trigger in SQL?
Answer: A trigger is a set of actions that are automatically executed when a
specific event occurs.
18. How do you delete data in SQL?
Answer: Using the DELETE statement.
19. What is a cursor in SQL?
Answer: A cursor is a control structure that allows you to iterate over the rows
of a table.
20. How do you optimize SQL queries?
Answer: By using indexes, optimizing database design, and minimizing the number
of queries.
-------------------------------------------------
Linux Basic Command Questions
1. What is the command to list all files and directories in Linux?
Answer: ls
2. How do you navigate to a specific directory in Linux?
Answer: cd /path/to/directory
3. What is the command to create a new directory in Linux?
Answer: mkdir directory_name
4. How do you delete a file in Linux?
Answer: rm file_name
5. What is the command to copy a file in Linux?
Answer: cp file_name destination
6. How do you move a file in Linux?
Answer: mv file_name destination
7. What is the command to check the current working directory in Linux?
Answer: pwd
8. How do you create a new file in Linux?
Answer: touch file_name
9. What is the command to view the contents of a file in Linux?
Answer: cat file_name
10. How do you search for a specific string in a file in Linux?
Answer: grep string file_name
11. What is the command to check the system's uptime in Linux?
Answer: uptime
12. How do you check the system's memory usage in Linux?
Answer: free -m
13. What is the command to check the system's disk usage in Linux?
Answer: df -h
14. How do you check the system's process list in Linux?
Answer: ps -ef
15. What is the command to kill a process in Linux?
Answer: kill process_id
16. How do you check the system's network connections in Linux?
Answer: netstat -an
17. What is the command to clear the terminal screen in Linux?
Answer: clear
18. How do you check the system's date and time in Linux?
Answer: date
19. What is the command to change the file permissions in Linux?
Answer: chmod permissions file_name
20. How do you check the system's user information in Linux?
Answer: whoami
14. Find employees who work in departments with the highest average salary
SELECT *
FROM employees
WHERE department_id IN (
SELECT department_id
FROM employees
GROUP BY department_id
HAVING AVG(salary) = (
SELECT MAX(avg_salary)
FROM (SELECT department_id, AVG(salary) AS avg_salary
FROM employees
GROUP BY department_id) AS avg_salaries
)
);
15. Find the total revenue generated by each product
SELECT products.product_name, SUM(orders.quantity * products.price) AS
total_revenue
FROM orders
JOIN products ON orders.product_id = products.product_id
GROUP BY products.product_name;
16. Write a SQL query to retrieve the order IDs and order totals for orders
that have a total value greater than the average order value of all orders,
but less than or equal to twice the average order value.
SELECT o.*
FROM Orders o
WHERE o.order_total > (
SELECT AVG(order_total)
FROM Orders
) AND o.order_total <= (
SELECT 2 * AVG(order_total)
FROM Orders
);
Question 10: Write a SQL query to retrieve the customer names who have placed orders with a total
value greater than the average total order value of all customers.
SELECT c.name
FROM Customers c
WHERE c.customer_id IN (
SELECT o.customer_id
FROM Orders o
GROUP BY o.customer_id
HAVING AVG(o.order_total) > (
SELECT AVG(order_total)
FROM Orders
)
);
1. What is the .NET Framework?
• Answer: The .NET Framework is a software development framework from Microsoft that
provides a controlled programming environment where software can be developed,
installed, and executed on Windows-based operating systems. It includes a large class
library (FCL) and provides language interoperability.
2. What is CLR in .NET?
• Answer: CLR (Common Language Runtime) is the virtual machine component of .NET. It
manages memory, execution of code, and other system services. It provides features such
as garbage collection, exception handling, and thread management.
3. What is the CTS?
• Answer: CTS (Common Type System) ensures that data types are understood by all .NET
languages. It defines how types are declared and used in the .NET framework, promoting
language interoperability.
4. What is the difference between .NET Core and .NET Framework?
• Answer: .NET Framework is a Windows-only platform, while .NET Core is cross-platform
(supports Windows, macOS, and Linux). .NET Core is open-source, modular, and designed
for more modern applications, including cloud-based apps.
5. Explain the concept of Managed Code.
• Answer: Managed Code is the code executed by the CLR. It ensures that code is safe,
memory is managed, and garbage collection occurs. Unmanaged code is executed directly
by the OS and requires manual memory management.
6. What is the difference between Value Type and Reference Type?
• Answer:
o Value Types store data directly, and the variables hold the actual value (e.g.,
int, char).
o Reference Types store a reference to the data. The variable contains a pointer
to the memory location (e.g., objects, arrays, strings).
7. What is the GAC in .NET?
• Answer: The Global Assembly Cache (GAC) is a machine-wide code cache for storing
assemblies that are shared among multiple applications. It allows multiple versions of
the same assembly to coexist on a system.
8. What is JIT Compilation?
• Answer: JIT (Just-In-Time) compilation compiles the intermediate language (IL) code
into native machine code at runtime. This optimizes the execution of .NET applications
by converting only the required code into machine instructions.
9. What is an Assembly in .NET?
• Answer: An assembly is a compiled code library used for deployment, versioning, and
security. It consists of one or more managed code modules (DLLs or EXEs) and metadata
that describes the code. It’s the building block of .NET applications.
10. Explain the concept of Garbage Collection in .NET.
• Answer: Garbage Collection (GC) is the process of automatically reclaiming memory that
is no longer in use by the application. The CLR manages this to prevent memory leaks by
freeing up memory occupied by objects that are no longer referenced.
11. What is ASP.NET?
• Answer: ASP.NET is a framework for building web applications and services with .NET. It
provides a way to build dynamic web pages, services, and APIs using languages such as
C# or VB.NET.
12. What is the difference between WebForms and MVC in ASP.NET?
• Answer:
o WebForms is event-driven and based on a page lifecycle model, where logic is
bound to controls and events on the page.
o MVC (Model-View-Controller) is a design pattern that separates an application
into three main components (Model, View, Controller), providing a cleaner
architecture and better control over HTML.
13. What is a Namespace in .NET?
• Answer: A Namespace is a logical grouping of related classes and types. It helps
organize code and avoid naming conflicts by grouping classes, interfaces, and enums.
14. What is the use of “using” keyword in .NET?
• Answer: The using keyword is primarily used for two purposes:
1. To include namespaces in your program.
2. To define a scope at the end of which an object will be disposed of (e.g., in
file or database connection handling).
15. What are Properties in .NET?
• Answer: Properties in .NET are special methods called accessors that expose private
fields of a class to external code. They provide a controlled way to access or modify
values (using get and set).
16. What is LINQ in .NET?
• Answer: LINQ (Language Integrated Query) is a .NET component that allows querying of
data from different sources (like databases, arrays, collections, etc.) in a SQL-like
syntax directly in C# or VB.NET.
17. Explain Delegates in .NET.
• Answer: A Delegate is a type-safe function pointer in .NET. It allows methods to be
passed as parameters. Delegates are used for implementing events and callback methods.
18. What are Events in .NET?
• Answer: Events are a way for a class to provide notifications to clients about certain
actions, such as a button click. Events use delegates as the underlying mechanism to
notify subscribers when something happens.
19. What is the purpose of ADO.NET?
• Answer: ADO.NET is a data access technology in .NET. It allows communication between
the application and the database using providers such as SQL Server, OLEDB, etc. It
supports connection, command, and data reader for data operations.
20. What is an Interface in .NET?
• Answer: An Interface defines a contract of methods and properties that must be
implemented by any class that inherits from it. Interfaces support multiple inheritance
and are useful in designing loosely-coupled systems.
### 1. **What is IIS?**
- **Answer**: IIS (Internet Information Services) is a flexible, secure, and manageable web
server created by Microsoft. It hosts websites and provides web services on Windows operating
systems.
### 2. **How do you install IIS on a Windows machine?**
- **Answer**: IIS can be installed through the "Turn Windows features on or off" dialog in
Control Panel, or by using PowerShell commands like `Install-WindowsFeature -name Web-Server -
IncludeManagementTools`.
### 3. **What is an Application Pool in IIS?**
- **Answer**: An Application Pool is a feature in IIS that isolates web applications from each
other. Each pool can run separate applications, providing better security, reliability, and
availability.
### 4. **How do you create a new website in IIS?**
- **Answer**: You create a new website by opening IIS Manager, right-clicking on "Sites" and
selecting "Add Website," then configuring the site name, physical path, and binding
information (port, IP address, etc.).
### 5. **What are bindings in IIS, and what are the main binding types?**
- **Answer**: Bindings define how IIS listens for incoming requests. The main binding types
are:
- **HTTP/HTTPS** (with port and SSL settings)
- **IP Address**
- **Host name**
### 6. **How do you secure a website using SSL in IIS?**
- **Answer**: You secure a website using SSL by first installing an SSL certificate on the
server, then configuring the site’s binding to use the HTTPS protocol and selecting the
installed certificate.
### 7. **How do you configure authentication in IIS?**
- **Answer**: In IIS Manager, under "Authentication" for a specific site or application, you
can enable and configure various authentication methods like Anonymous, Basic, Forms, or
Windows Authentication.
### 8. **What is the purpose of the `web.config` file in IIS?**
- **Answer**: The `web.config` file is an XML configuration file used to manage settings for
web applications hosted in IIS. It can control security settings, URLs, session management,
custom error pages, and more.
### 9. **How do you deploy an ASP.NET application to IIS?**
- **Answer**: To deploy an ASP.NET application, you:
1. Publish the application using Visual Studio or any other deployment tool.
2. Copy the published files to the website’s physical path in IIS.
3. Configure the application pool and bindings.
4. Ensure necessary permissions are set for the application folder.
### 10. **How do you troubleshoot a website that is not loading in IIS?**
- **Answer**: Basic steps include:
- Checking if the site is started in IIS Manager.
- Verifying binding settings (port, IP address).
- Reviewing the Event Viewer for error logs.
- Checking `IIS logs` located in `C:\inetpub\logs\LogFiles`.
- Confirming permissions and firewall settings are correct.
o connect a .NET application to a website, particularly in IIS (Internet Information Services),
you need to deploy the .NET application to the web server. Here's a step-by-step guide:
Step 1: Publish the .NET Application
1. Open the Project in Visual Studio:
o Open the .NET web application (ASP.NET MVC/Core or WebForms) in Visual Studio.
2. Publish the Application:
o Right-click the project in the Solution Explorer.
o Select Publish.
o Choose a publishing method:
▪ Folder: Publish to a local folder, then manually copy the files to the server.
▪ FTP: Publish directly to a remote server via FTP.
▪ Web Deploy: Deploy directly to IIS if it's running on the same machine.
o Complete the publish wizard and ensure the application builds successfully.
Step 2: Set Up IIS for Hosting
1. Install IIS:
o Ensure IIS is installed on your server or machine (Control Panel > Turn Windows Features on or off > Enable IIS).
2. Add a New Website:
o Open IIS Manager (inetmgr in the Run dialog).
o Right-click Sites and select Add Website.
o Enter a site name and the physical path where your .NET application is stored (the folder where you published it).
o Set the Binding (IP address, port, and optionally hostname).
o Click OK.
Step 3: Set the Application Pool
1. Create or Use an Existing Application Pool:
o In IIS Manager, go to Application Pools.
o Create a new application pool or select the existing one.
o If using .NET Core, ensure the application pool is set to No Managed Code.
o For ASP.NET, set the application pool to the corresponding .NET CLR version.
2. Assign the Application Pool to Your Website:
o Right-click the newly created website, select Manage Website > Advanced Settings.
o In the Application Pool section, choose the appropriate pool for your app.
Step 4: Configure Permissions
1. Folder Permissions:
o Make sure the folder where your website files are located has the correct permissions.
o The IIS_IUSRS group must have read and execute access.
o For upload directories or logs, grant write permissions if needed.
Step 5: Test the Website
1. Browse the Site:
o Open your browser and navigate to the URL or IP address configured in IIS, followed by the port number (if not using
default port 80).
o Example: http://localhost or http://localhost:8080 (if using port 8080).
Step 6: Enable ASP.NET Core/ASP.NET Support (If Needed)
1. Install the .NET Core Hosting Bundle (for .NET Core):
o If you're hosting a .NET Core app, you need to install the .NET Core Hosting Bundle on the server. This installs the
ASP.NET Core Module for IIS.
o You can download it from the official .NET website.
2. Enable ASP.NET Features:
o If you're hosting an ASP.NET (Framework) application, ensure that the ASP.NET and .NET Framework features are
enabled in IIS under Windows Features.
Step 7: Restart IIS
• After setting up everything, restart IIS to ensure changes are applied:
o Run iisreset in Command Prompt.
Example
If you have a .NET Core MVC app, after publishing it, the folder structure will contain the necessary files (DLLs, views, etc.). After copying the
files to the physical path in IIS and setting up the site, navigating to http://localhost (or your IP) will serve the .NET application.
Troubleshooting:
• Logs: If the website does not load, check the IIS logs (C:\inetpub\logs\LogFiles) and Event Viewer for detailed error
messages.
• Application Pool Settings: Make sure your application pool is running and configured for the correct .NET version.
This will connect your .NET application to the website hosted in IIS.