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)