.NET Fresher Interview Questions Interview Questions and Answers
Practice every question in this topic using expandable answers and interview tips. Answer aloud first, then open the explanation.
Back to the complete interview hub
Q1. What is .NET? [Easy]
Answer: .NET is a cross-platform, open-source software development platform developed by Microsoft for building web, mobile, desktop, cloud, IoT, and AI applications.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q2. What is CLR in .NET? [Easy]
Answer: CLR (Common Language Runtime) is the execution engine of .NET that compiles Intermediate Language (CIL) to machine code via JIT and manages memory, security, and thread execution.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q3. What is CTS and CLS in .NET? [Easy]
Answer: CTS (Common Type System) defines standardized data types for cross-language compatibility. CLS (Common Language Specification) defines compiler rules that languages must follow for interoperability.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q4. What is managed vs unmanaged code in .NET? [Medium]
Answer: Managed code executes under CLR control with automatic garbage collection and safety checks. Unmanaged code executes directly on the OS outside CLR control (e.g. C/C++ DLLs).
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q5. How does Garbage Collection work in .NET? [Medium]
Answer: Garbage Collection (GC) automatically reclaims memory occupied by dead/unreferenced objects on the managed heap across Generations 0, 1, and 2.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q6. What is an assembly in .NET? [Easy]
Answer: An assembly is a compiled, reusable building block of .NET applications (either a .dll library or .exe executable) containing bytecode CIL, metadata, and manifest.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q7. What is a namespace in .NET? [Easy]
Answer: A namespace logically organizes related classes, interfaces, and structures while preventing class name collisions across projects.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q8. What is ASP.NET Core? [Easy]
Answer: ASP.NET Core is a modern, high-performance, open-source, cross-platform framework for building cloud-connected web applications, REST APIs, and microservices.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q9. What is the MVC pattern in ASP.NET Core? [Medium]
Answer: MVC stands for Model (Data & Business Logic), View (UI layout rendering), and Controller (Handles HTTP requests and coordinates Model and View).
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q10. What is REST API in .NET? [Medium]
Answer: A REST API is an HTTP-based service architecture using standard HTTP methods (GET, POST, PUT, DELETE) to manage resources usually formatted as JSON.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q11. What is Dependency Injection in ASP.NET Core? [Hard]
Answer: Dependency Injection (DI) is a built-in design pattern where required service instances are injected into constructors rather than instantiated directly, promoting loose coupling.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q12. What is middleware in ASP.NET Core? [Hard]
Answer: Middleware consists of software components assembled into an HTTP request processing pipeline to handle logging, authentication, routing, and exception handling.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q13. What is Entity Framework Core (EF Core)? [Medium]
Answer: Entity Framework Core is an Object-Relational Mapper (ORM) that enables .NET developers to query and update databases using strongly typed C# objects instead of SQL.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q14. What is ADO.NET? [Easy]
Answer: ADO.NET is a set of core .NET classes (SqlConnection, SqlCommand, SqlDataReader, SqlDataAdapter) for direct low-level relational database interaction.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q15. What is the difference between Authentication and Authorization? [Medium]
Answer: Authentication verifies who the user is (e.g. login credentials). Authorization determines what resources or permissions the authenticated user can access.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q16. What is appsettings.json in ASP.NET Core? [Easy]
Answer: appsettings.json is the primary configuration file storing app settings, database connection strings, logging options, and environment variables.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q17. What is the difference between .NET Framework and modern .NET (.NET Core)? [Easy]
Answer: .NET Framework is a legacy, Windows-only platform. Modern .NET (formerly .NET Core) is a cross-platform, open-source, and highly modular framework designed for high performance, cloud-native apps, and microservices across Windows, Linux, and macOS.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q18. What are the Dependency Injection (DI) service lifetimes in ASP.NET Core? [Medium]
Answer: ASP.NET Core supports three DI lifetimes: Transient (created anew every time it is requested), Scoped (created once per HTTP client request), and Singleton (created only once for the entire lifetime of the application).
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q19. What is Middleware in ASP.NET Core? [Medium]
Answer: Middleware components are software modules assembled into the application pipeline to handle incoming HTTP requests and outgoing responses. They execute in a specific order; each can process a request, and either pass it to the next middleware or terminate the pipeline.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q20. What is the difference between app.Use() and app.Run() when configuring Middleware? [Hard]
Answer: app.Use() adds middleware that has the ability to call the next middleware in the pipeline using the 'next' delegate. app.Run() delegates act as terminal middleware, meaning they completely handle the request and prevent any subsequent middleware from executing.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q21. What is Kestrel? [Medium]
Answer: Kestrel is the default, cross-platform, open-source web server for ASP.NET Core applications. It is highly optimized for asynchronous I/O and performance, and it can run independently as an edge server or behind a reverse proxy like IIS or Nginx.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q22. What is the Options Pattern in ASP.NET Core? [Hard]
Answer: The Options Pattern uses classes to provide strongly-typed configuration settings. It leverages interfaces like IOptions<T>, IOptionsSnapshot<T>, or IOptionsMonitor<T> to bind configuration data (e.g., from appsettings.json) and inject it as dependencies.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q23. What are Minimal APIs in ASP.NET Core? [Easy]
Answer: Minimal APIs are a lightweight approach for building fast HTTP APIs with minimal dependencies and boilerplate code. They allow developers to map routes and handle requests directly in Program.cs without needing traditional MVC Controllers.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q24. How can you implement background tasks in .NET? [Medium]
Answer: Background tasks are typically implemented by inheriting from the BackgroundService base class or directly implementing the IHostedService interface. This allows long-running asynchronous operations to run independently of HTTP requests.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q25. What is the difference between JWT Authentication and OAuth2? [Hard]
Answer: JWT (JSON Web Token) is a stateless token format used to securely assert identity and claims. OAuth2 is a broader authorization framework/protocol that dictates how clients can securely obtain access tokens (which are often JWTs) to act on behalf of a user.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q26. What is the purpose of AsNoTracking() in Entity Framework Core? [Medium]
Answer: AsNoTracking() instructs EF Core not to store retrieved entities in its internal change tracker. This significantly improves read performance and reduces memory usage for queries where the data is purely for display and will not be updated.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q27. What are Action Filters in ASP.NET Core MVC? [Medium]
Answer: Action Filters are attributes that allow you to run custom code synchronously or asynchronously before or after an action method executes. They are commonly used for cross-cutting concerns like logging, caching, authorization, or input validation.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q28. How do you handle global exceptions in ASP.NET Core API? [Hard]
Answer: Global exceptions are typically handled using the built-in UseExceptionHandler middleware in Program.cs. In modern .NET, developers often implement the IExceptionHandler interface to cleanly catch exceptions and return standardized ProblemDetails JSON responses.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Q29. What is CORS, and how do you enable it in ASP.NET Core? [Medium]
Answer: CORS (Cross-Origin Resource Sharing) is a browser security mechanism that restricts web applications running at one origin from accessing resources at a different origin. It is enabled in ASP.NET Core using the UseCors() middleware alongside configured CORS policies.
Interview tip: Define it clearly, give a small example, and mention one practical use or limitation.
Study checklist
- Explain the answer without reading.
- Write one small example.
- Compare framework or database version differences in official documentation.
.NET Fresher Interview Questions Interview Questions and Answers
Practice one question at a time. Read the question, answer aloud, then compare your explanation with the answer.
← Back to the complete interview hub
Q1. What is .NET?
Easy
Answer: .NET is a cross-platform, open-source software development platform developed by Microsoft for building web, mobile, desktop, cloud, IoT, and AI applications.
Interview tip: Use a short example and connect the answer to real project work.
Q2. What is CLR in .NET?
Easy
Answer: CLR (Common Language Runtime) is the execution engine of .NET that compiles Intermediate Language (CIL) to machine code via JIT and manages memory, security, and thread execution.
Interview tip: Use a short example and connect the answer to real project work.
Q3. What is CTS and CLS in .NET?
Easy
Answer: CTS (Common Type System) defines standardized data types for cross-language compatibility. CLS (Common Language Specification) defines compiler rules that languages must follow for interoperability.
Interview tip: Use a short example and connect the answer to real project work.
Q4. What is managed vs unmanaged code in .NET?
Medium
Answer: Managed code executes under CLR control with automatic garbage collection and safety checks. Unmanaged code executes directly on the OS outside CLR control (e.g. C/C++ DLLs).
Interview tip: Use a short example and connect the answer to real project work.
Q5. How does Garbage Collection work in .NET?
Medium
Answer: Garbage Collection (GC) automatically reclaims memory occupied by dead/unreferenced objects on the managed heap across Generations 0, 1, and 2.
Interview tip: Use a short example and connect the answer to real project work.
Q6. What is an assembly in .NET?
Easy
Answer: An assembly is a compiled, reusable building block of .NET applications (either a .dll library or .exe executable) containing bytecode CIL, metadata, and manifest.
Interview tip: Use a short example and connect the answer to real project work.
Q7. What is a namespace in .NET?
Easy
Answer: A namespace logically organizes related classes, interfaces, and structures while preventing class name collisions across projects.
Interview tip: Use a short example and connect the answer to real project work.
Q8. What is ASP.NET Core?
Easy
Answer: ASP.NET Core is a modern, high-performance, open-source, cross-platform framework for building cloud-connected web applications, REST APIs, and microservices.
Interview tip: Use a short example and connect the answer to real project work.
Q9. What is the MVC pattern in ASP.NET Core?
Medium
Answer: MVC stands for Model (Data & Business Logic), View (UI layout rendering), and Controller (Handles HTTP requests and coordinates Model and View).
Interview tip: Use a short example and connect the answer to real project work.
Q10. What is REST API in .NET?
Medium
Answer: A REST API is an HTTP-based service architecture using standard HTTP methods (GET, POST, PUT, DELETE) to manage resources usually formatted as JSON.
Interview tip: Use a short example and connect the answer to real project work.
Q11. What is Dependency Injection in ASP.NET Core?
Hard
Answer: Dependency Injection (DI) is a built-in design pattern where required service instances are injected into constructors rather than instantiated directly, promoting loose coupling.
Interview tip: Use a short example and connect the answer to real project work.
Q12. What is middleware in ASP.NET Core?
Hard
Answer: Middleware consists of software components assembled into an HTTP request processing pipeline to handle logging, authentication, routing, and exception handling.
Interview tip: Use a short example and connect the answer to real project work.
Q13. What is Entity Framework Core (EF Core)?
Medium
Answer: Entity Framework Core is an Object-Relational Mapper (ORM) that enables .NET developers to query and update databases using strongly typed C# objects instead of SQL.
Interview tip: Use a short example and connect the answer to real project work.
Q14. What is ADO.NET?
Easy
Answer: ADO.NET is a set of core .NET classes (SqlConnection, SqlCommand, SqlDataReader, SqlDataAdapter) for direct low-level relational database interaction.
Interview tip: Use a short example and connect the answer to real project work.
Q15. What is the difference between Authentication and Authorization?
Medium
Answer: Authentication verifies who the user is (e.g. login credentials). Authorization determines what resources or permissions the authenticated user can access.
Interview tip: Use a short example and connect the answer to real project work.
Q16. What is appsettings.json in ASP.NET Core?
Easy
Answer: appsettings.json is the primary configuration file storing app settings, database connection strings, logging options, and environment variables.
Interview tip: Use a short example and connect the answer to real project work.
Q17. What is the difference between .NET Framework and modern .NET (.NET Core)?
Easy
Answer: .NET Framework is a legacy, Windows-only platform. Modern .NET (formerly .NET Core) is a cross-platform, open-source, and highly modular framework designed for high performance, cloud-native apps, and microservices across Windows, Linux, and macOS.
Interview tip: Use a short example and connect the answer to real project work.
Q18. What are the Dependency Injection (DI) service lifetimes in ASP.NET Core?
Medium
Answer: ASP.NET Core supports three DI lifetimes: Transient (created anew every time it is requested), Scoped (created once per HTTP client request), and Singleton (created only once for the entire lifetime of the application).
Interview tip: Use a short example and connect the answer to real project work.
Q19. What is Middleware in ASP.NET Core?
Medium
Answer: Middleware components are software modules assembled into the application pipeline to handle incoming HTTP requests and outgoing responses. They execute in a specific order; each can process a request, and either pass it to the next middleware or terminate the pipeline.
Interview tip: Use a short example and connect the answer to real project work.
Q20. What is the difference between app.Use() and app.Run() when configuring Middleware?
Hard
Answer: app.Use() adds middleware that has the ability to call the next middleware in the pipeline using the 'next' delegate. app.Run() delegates act as terminal middleware, meaning they completely handle the request and prevent any subsequent middleware from executing.
Interview tip: Use a short example and connect the answer to real project work.
Q21. What is Kestrel?
Medium
Answer: Kestrel is the default, cross-platform, open-source web server for ASP.NET Core applications. It is highly optimized for asynchronous I/O and performance, and it can run independently as an edge server or behind a reverse proxy like IIS or Nginx.
Interview tip: Use a short example and connect the answer to real project work.
Q22. What is the Options Pattern in ASP.NET Core?
Hard
Answer: The Options Pattern uses classes to provide strongly-typed configuration settings. It leverages interfaces like IOptions<T>, IOptionsSnapshot<T>, or IOptionsMonitor<T> to bind configuration data (e.g., from appsettings.json) and inject it as dependencies.
Interview tip: Use a short example and connect the answer to real project work.
Q23. What are Minimal APIs in ASP.NET Core?
Easy
Answer: Minimal APIs are a lightweight approach for building fast HTTP APIs with minimal dependencies and boilerplate code. They allow developers to map routes and handle requests directly in Program.cs without needing traditional MVC Controllers.
Interview tip: Use a short example and connect the answer to real project work.
Q24. How can you implement background tasks in .NET?
Medium
Answer: Background tasks are typically implemented by inheriting from the BackgroundService base class or directly implementing the IHostedService interface. This allows long-running asynchronous operations to run independently of HTTP requests.
Interview tip: Use a short example and connect the answer to real project work.
Q25. What is the difference between JWT Authentication and OAuth2?
Hard
Answer: JWT (JSON Web Token) is a stateless token format used to securely assert identity and claims. OAuth2 is a broader authorization framework/protocol that dictates how clients can securely obtain access tokens (which are often JWTs) to act on behalf of a user.
Interview tip: Use a short example and connect the answer to real project work.
Q26. What is the purpose of AsNoTracking() in Entity Framework Core?
Medium
Answer: AsNoTracking() instructs EF Core not to store retrieved entities in its internal change tracker. This significantly improves read performance and reduces memory usage for queries where the data is purely for display and will not be updated.
Interview tip: Use a short example and connect the answer to real project work.
Q27. What are Action Filters in ASP.NET Core MVC?
Medium
Answer: Action Filters are attributes that allow you to run custom code synchronously or asynchronously before or after an action method executes. They are commonly used for cross-cutting concerns like logging, caching, authorization, or input validation.
Interview tip: Use a short example and connect the answer to real project work.
Q28. How do you handle global exceptions in ASP.NET Core API?
Hard
Answer: Global exceptions are typically handled using the built-in UseExceptionHandler middleware in Program.cs. In modern .NET, developers often implement the IExceptionHandler interface to cleanly catch exceptions and return standardized ProblemDetails JSON responses.
Interview tip: Use a short example and connect the answer to real project work.
Q29. What is CORS, and how do you enable it in ASP.NET Core?
Medium
Answer: CORS (Cross-Origin Resource Sharing) is a browser security mechanism that restricts web applications running at one origin from accessing resources at a different origin. It is enabled in ASP.NET Core using the UseCors() middleware alongside configured CORS policies.
Interview tip: Use a short example and connect the answer to real project work.
Quick revision checklist
- Explain the answer without reading.
- Write one small example.
- Review platform or version differences in official documentation.
No comments:
Post a Comment
Please do not enter any spam link in the comment box.