DEV Community

Cover image for πŸ”· Top 20+ .NET & OOPs Interview Questions (Easy Guide for Freshers)
Sapana Pal
Sapana Pal

Posted on

πŸ”· Top 20+ .NET & OOPs Interview Questions (Easy Guide for Freshers)

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}");
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή 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
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή 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)