Are you preparing for a .NET Developer interview? Here's a quick and clear guide covering OOPs, .NET, MVC, Web API, and SQL Server questions with short, simple answers β perfect for quick revision!
πΉ OOPs (Object-Oriented Programming)
1. What are the 4 pillars of OOP?
- Encapsulation β Bundling data and methods together
- Abstraction β Hiding complexity, showing only essentials
- Inheritance β Reusing code via base/derived classes
- Polymorphism β One interface, many implementations (overloading/overriding)
2. Difference between Abstraction and Encapsulation
Concept | Abstraction | Encapsulation |
---|---|---|
Focus | Hides what happens inside | Hides how data is stored |
Use | Interfaces/abstract classes | Access modifiers |
3. Interface vs Abstract Class in C#
Feature | Abstract Class | Interface |
---|---|---|
Methods | Can have definitions | Only signatures (till C# 8) |
Modifiers | Access modifiers allowed | All members are public |
Inheritance | Single inheritance | Multiple interfaces supported |
4. Overloading vs Overriding
- Overloading: Same method name, different parameters (compile-time)
- Overriding: Redefines base method in derived class (runtime)
πΉ .NET & C# Interview Questions
5. Difference between ref
and out
?
- ref: Must be initialized before passing
- out: No need to initialize; must be assigned inside the method
6. What is Garbage Collection in .NET?
The Garbage Collector (GC) automatically frees memory by destroying unused objects.
7. Difference between ==
and .Equals()
- ==: Compares values (for value types) or references (for objects)
- .Equals(): Can compare content, can be overridden
πΉ ASP.NET MVC Questions
8. What is MVC Architecture?
- Model: Business logic & data
- View: UI layer
- Controller: Handles user input & updates Model/View
9. What is Routing in MVC?
Maps URLs to controller/action methods.
routes.MapRoute("Default", "{controller}/{action}/{id}");
πΉ 10. TempData vs ViewData vs ViewBag
Feature | ViewData | ViewBag | TempData |
---|---|---|---|
Type | Dictionary | Dynamic | Dictionary |
Lifetime | Current request | Current request | Current + next request |
Use Case | Data to View | Data to View | Across redirects |
πΉ 11. What are Action Filters in MVC?
Action Filters allow you to run logic before or after an action method executes in a controller.
Examples:
-
[Authorize]
β Restrict access -
[HandleError]
β Handle exceptions -
[OutputCache]
β Cache output
πΉ Web API Questions
12. What is Web API in .NET?
ASP.NET Web API is a framework to build RESTful HTTP services, used in web, mobile, or desktop applications. It supports content negotiation (JSON/XML) and is lightweight.
13. Difference: Web API vs MVC
Feature | MVC | Web API |
---|---|---|
Purpose | Returns HTML Views | Returns data (JSON, XML) |
Return Type | ViewResult |
JsonResult , IHttpActionResult
|
14. How to Secure Web API?
- π Use JWT tokens or OAuth 2.0
- π‘οΈ Implement Authorization filters
- π Use HTTPS to encrypt communication
15. Common HTTP Verbs in Web API
- GET β Read data
- POST β Create new data
- PUT β Replace entire resource
- PATCH β Update partial resource
- DELETE β Remove data
πΉ SQL Server Interview Questions
16. WHERE vs HAVING
-
WHERE: Filters rows before
GROUP BY
-
HAVING: Filters groups after
GROUP BY
17. Types of SQL Joins
- πΉ INNER JOIN β Returns matching rows from both tables
- πΉ LEFT JOIN β All rows from left + matched rows from right
- πΉ RIGHT JOIN β All rows from right + matched from left
- πΉ FULL OUTER JOIN β All rows when there's a match in either table
- πΉ CROSS JOIN β Cartesian product (every combination)
18. DELETE vs TRUNCATE
Feature | DELETE | TRUNCATE |
---|---|---|
Logging | Logs each row | Minimal logging |
WHERE | Allowed | Not allowed |
Rollback | Yes | Not guaranteed |
19. What is a Stored Procedure?
A Stored Procedure is a precompiled set of SQL statements stored in the database to perform a specific task.
CREATE PROCEDURE GetEmployees
AS
BEGIN
SELECT * FROM Employees
END
πΉ 20. What is Indexing in SQL?
Indexing is a technique used to speed up data retrieval in SQL tables by reducing the amount of data the database engine has to scan.
π Types of Indexes:
- πΈ Clustered Index β Sorts and stores data rows in the table based on the key values. Only one per table.
- πΈ Non-Clustered Index β Stores index separately from actual table data. Multiple allowed per table.
- πΈ Unique Index β Ensures all values in the index key are unique.
- πΈ Full-Text Index β Used for searching text-based columns (e.g., LIKE, CONTAINS).
π‘ Quick Tip:
π― Be clear and confident in your explanations.
π οΈ Practice real-world SQL queries and indexing scenarios.
π Revise these questions regularly to stay sharp before interviews.
π Pro Tip:
When dealing with large datasets, indexing can drastically improve performance β especially on WHERE
, JOIN
, and ORDER BY
queries.
Top comments (0)