Top .NET Interview Questions and Answers

Here are top .net interview questions,


1. What is .NET?

.NET is a free, open-source framework developed by Microsoft that allows developers to build a variety of applications, including web, desktop, mobile, and cloud-based applications.

 

2. What are the different components of .NET?

.NET consists of the Common Language Runtime (CLR), the Framework Class Library (FCL), and various development tools, such as compilers, debuggers, and code editors.

 

3. What is the Common Language Runtime (CLR)?

The Common Language Runtime is the execution environment provided by .NET. It manages the execution of .NET programs, including memory management, garbage collection, security, and exception handling.

 

4. What is the difference between value types and reference types in .NET?

Value types store their data directly, while reference types store a reference to their data. Value types are stored on the stack, and reference types are stored on the heap.

 

5. What is the Global Assembly Cache (GAC)?

The Global Assembly Cache is a central repository in .NET that stores shared assemblies. Shared assemblies are accessible by multiple applications and can be accessed from any location on the system.

 

6. What is the difference between an abstract class and an interface?

An abstract class can have both method implementations and abstract members, while an interface only defines method signatures. A class can inherit from only one abstract class but can implement multiple interfaces.

 

7. What is the purpose of the AppDomain class in .NET?

The AppDomain class is a sandboxed environment within which .NET applications run. It provides isolation, security, and the ability to unload assemblies.

 

8. What is garbage collection in .NET?

Garbage collection is an automatic memory management feature in .NET. It automatically reclaims memory occupied by objects that are no longer referenced, freeing developers from manual memory management.

 

9. What are the different types of JIT (Just-In-Time) compilation in .NET?

.NET has two types of JIT compilation: Pre-JIT (compile entire code to native code before execution) and Just-In-Time (compile code on demand, method by method).

 

10. What is the purpose of the web.config file in ASP.NET?

The web.config file is a configuration file in ASP.NET that contains settings and configurations specific to a web application. It includes information about database connections, security settings, and custom application settings.

 

11. What is a delegate in .NET?

A delegate is a type that represents a reference to a method. It allows methods to be passed as parameters, stored in variables, and invoked dynamically at runtime.

 

12. What is the difference between a class and a struct in .NET?

A class is a reference type, while a struct is a value type. Classes are allocated on the heap, and structs are allocated on the stack or inline within a containing type.

 

13. What is the purpose of the ViewState in ASP.NET?

ViewState is a mechanism in ASP.NET that allows the preservation of page and control state across postbacks. It stores the state information in a hidden field on the page.

 

14. What is the difference between a user control and a custom control in ASP.NET?

A user control is a reusable control created by combining existing controls and markup, while a custom control is a control derived from the base Control class and provides custom behavior.

 

15. What is the difference between an assembly and a namespace in .NET?

An assembly is a compiled unit of code that can contain one or more namespaces. A namespace provides a way to organize and group related classes and types.

 

16. What is the purpose of the DataReader class in ADO.NET?

The DataReader class in ADO.NET provides a forward-only, read-only stream of data from a database. It is used to efficiently retrieve large amounts of data without caching the entire result set in memory.

 

17. What is the difference between late binding and early binding in .NET?

Late binding resolves method calls and property accesses at runtime, allowing for dynamic behavior. Early binding, on the other hand, resolves them at compile-time, providing better performance but less flexibility.

 

18. What is the purpose of the ASP.NET Application_Start event?

The Application_Start event in ASP.NET is fired when the first request is made to the application. It is used to initialize global application-level resources and settings.

 

19. What is the difference between WCF and Web API in .NET?

WCF (Windows Communication Foundation) is a framework for building service-oriented applications, while Web API is a framework for building HTTP-based services that can be consumed by a variety of clients.

 

20. What is the purpose of the using statement in C#?

The using statement in C# is used to automatically release resources (such as file handles or database connections) once they are no longer needed. It ensures proper cleanup and avoids memory leaks.


Above are few top .net interview questions. Remember to prepare and expand on these answers.

Good luck with your interview!  👍


Post a Comment

0 Comments