Top .Net Interview Questions and Answers for 2023
Seeking .NET interview questions and answers? Explore our curated list of commonly asked questions, accompanied by detailed answers and insightful explanations.
.NET is among the most powerful frameworks to create a range of applications for Windows Desktop, Web applications, Windows Phone applications, Windows Store applications, Windows Server, Windows Azure (cloud), as well as Bot frameworks and cognitive services. .NET has proved to be an ever-growing employment segment that requires skilled professionals who can handle the task of creating applications efficiently. This article lists the top dot net interview questions and answers to help you succeed in a dot net job interview.
Top Dot Net (.Net) Interview Questions and Answers
Here are the top dot net interview questions that you should prepare for. These dot net interview questions will help freshers and experienced candidates clear your next .Net interview.
Best-suited Interview preparation courses for you
Learn Interview preparation with these high-rated online courses
Q1. What is .NET?
Ans. .Net is a software framework of Microsoft for developing applications on Windows. It is similar to other software development frameworks like Java Platform, and Enterprise Edition (J2EE), and comprises ASP .Net, languages such as C#, VB .Net, COBOL, Perl, etc.
Explore free .Net Courses
Q2. What is ASP.NET?
Ans. ASP.NET is another software framework to build web applications and is a part of the .NET Framework. ASP.NET helps to build the front end and runs on IIS, a Web Server.
Q3. What is CLR?
Ans. CLR refers to Common Language Run-time. It is an essential component of the .NET framework and can be used as a building block of various applications. An essential feature of CLR is ensuring a secure execution environment for applications.
Q4. What is CLS?
Ans. CLS refers to Common Language Specification. It allows users to use inter-language compatible components and helps to reuse the code in other .NET compatible languages.
Q5. Differentiate between boxing and unboxing.
Ans. The following is the difference between boxing and unboxing:
Boxing | Unboxing |
Implicit conversion | Explicit conversion |
Object type refers to the value type | Retrieve value from the boxed object |
int n = 12; object ob = n; |
int m = (int) ob; |
Q6. What is BCL?
Ans. BCL refers to Base Class Library. It is the foundation of .NET framework applications, components, and controls. It comprises basic, fundamental types like Systems.String and System.DateTime and offers functionalities like threading, input/output, security, diagnostics, etc.
Q7. What are cookies?
Ans. Cookies are small bits of text information. Cookies are created by the server on the client to identify users. It may contain the username and ID, interests, password remember option, or any other information. Cookies are domain-specific.
Q8. Name some of the disadvantages of cookies.
Ans. The main disadvantages of cookies include:
- Possible security risk, as they are stored in a clear text
- Not secure, as encryption & decryption is easy
- Cookies can be disabled on any user’s computer
- Can be edited or deleted
- Cookies can store limited data.
Q9. How many languages are supported by .NET?
Ans. .NET supports almost 60 languages, including:
- C#.NET
- VB.NET
- C++.NET
- J#.NET
- F#.NET
- JSCRIPT.NET
- WINDOWS POWERSHELL
Check Out Popular Programming Courses
Q10. Differentiate between ASP.NET and ASP.
Ans. Yes, ASP.NET is different from ASP. The following are the main differences:
ASP.NET | Active Server Pages (ASP) |
Creates dynamic web applications | Creates web pages |
Compiled | Interpreted |
Uses ADO.NET | Uses ADO |
Completely object-oriented | Partially object-oriented |
Q11. Explain state management in ASP.NET.
Ans. State management is managing the state of one or more user interface controls, such as text fields, OK buttons, radio buttons, etc., in a graphical user interface. Two types of state management systems are there in ASP.NET –
- Client-side state management
- Server-side state management
Q12. What are the key differences between function and stored procedure in .Net programming language?
Ans. The difference between function and stored procedure:
Function | Stored procedure |
Returns only one value | Returns one or more than one value |
Used in select statements | Cannot be used in select statements |
Has only input parameter | Has both input and output parameters |
It can’t handle exceptions | It can handle exceptions using a try-catch block |
Q13. How would you retrieve user names for Windows Authentication?
Ans. User name for Windows Authentication can be retrieved by using:
System.Environment.UserName
Q14. Name the advantages of using Session State.
Ans. The advantages of Session State include –
- Easy to implement
- Stores user states and data across the application
- Ensures data durability
- Works in multi-process configuration, thereby ensuring platform scalability
- Stores session object on the server. Keeping it secure and transparent for the user
Q15. What is HTTPhandler?
Ans. HttpHandler is a low-level request and response API in ASP.Net. The ASP.NET web application server uses it to handle specific extension-based requests.
Q16. Name the methodology used to enforce garbage collection in .NET.
Ans. The methodology used to enforce garbage collection in .NET is System.GC.Collect().
Q17. How many types of indexes are there in .NET?
Ans. There are two types of indexes in .Net:
- Clustered index
- Non-clustered index
Q18. How many types of memories exist in .Net?
Ans. There are two types of memories in .Net
- Stack memory
- Heap Memory
Q19. What is IL?
Ans. IL refers to Intermediate Language and is an object-oriented programming language to be used by compilers. It changes to byte code when a virtual machine is being executed. IL is also known as Common Intermediate Language (CIL) or Microsoft Intermediate Language (MSIL).
Q19. What is inheritance? Explain its importance.
Ans. Inheritance is a crucial aspect of object-oriented programming that allows developers to create new classes built upon existing classes. This is achieved by reusing, extending, and modifying the behaviours defined in classes. The class whose members are inherited is the base class, while the class that inherits those members is called the derived class.
Q20. What is LINQ?
Ans. LINQ notices to Language Integrated Query. It was introduced with visual studio 2008 and is a uniform query syntax in C# and VB.NET for data retrieval from different sources and data manipulation irrespective of the data source.
Q21. Name different types of constructors in C#.
Ans. Different types of constructors in C# are Copy Constructor, Default Constructor, Parameterized constructor, Private Constructor, and Static Constructor.
Q22. Write the differences between Custom Control and User Control.
Ans. Custom control and user control differ as follows:
Custom Control | User Control |
Inherits from the System.Windows.Controls.Control class | Inherits from the system.Windows.Controls.UserControls class |
Designed for single-application scenarios | Designed for multi-application scenarios |
Introduces redundancy and maintenance problems if used on more than one application | Can be distributed without facing any problems associated with redundancy and maintenance |
Loosely coupled control with respect to code and UI | Tightly coupled control with respect to code and UI |
Q23. What is Garbage Collector in .NET?
Ans. The garbage collector frees up the unused code objects in the memory. Every time a new object is created, the common language runtime allocates memory for the object.
Q24. What are the different events in the Page Life Cycle?
Ans. Different events in the Page Life Cycle include:
- Page_PreInit
- Page_Init
- Page_InitComplete
- Page_PreLoad
- Page_Load
- Page_LoadComplete
- Page_PreRender
- Render
Q25. Name all the templates of the Repeater control.
Ans. Templates of the Repeater control are:
- ItemTemplate
- AlternatingItemTemplate
- SeparatorTemplate
- HeaderTemplate
- FooterTemplate
Q26. What code can we use to send e-mail from an ASP.NET application?
Ans. We can write a given code to send an e-mail:
MailMessage mailMess = new MailMessage ();
mailMess.From = “naukri@gmail.com”;
mailMess.To = “shiksha@gmail.com”;
mailMess.Subject = “Test email”;
mailMess.Body = “Hi check this test mail.”;
SmtpMail.SmtpServer = “localhost”;
SmtpMail.Send (mailMess);
MailMessage and SmtpMail are classes defined System.Web.Mail namespace.
Q27. Explain Polymorphism.
Ans. Polymorphism is used as an interface with various functions. In this interface, a similar method or property can work on different actions depending on the run-time type of the instance.
Q28. Mention different types of Polymorphism.
Ans. Following are two types of Polymorphism:
- Static or compile-time polymorphism
- Dynamic or runtime polymorphism
Q29. Mention the design principles used in .NET.
Ans. In .Net, SOLID design principle is used. Take a look at the following design principles:
- Open-Closed Principle (OCP)
- Single responsibility principle (SRP)
- Interface segregation principle (ISP)
- Liskov substitution principle (LSP)
- Dependency inversion principle (DIP)
Q30. Explain Marshaling in .Net.
Ans. Marshaling is defined as transforming types in managed and unmanaged code. It is the most important service given by CLR.
Q31. What are Boxing and Unboxing?
Ans. Boxing and Unboxing are defined as a concept of C#, where a unified view of the type system is enabled to treat the value of any type as an object.
Explore the Top 10 Programming Language to Learn
Q32. Mention the divisions of the Memory Heap?
Ans. Following is the division of the memory heap into three generations.
Generation 0 – Used to store short-lived objects. Quick Garbage Collection occurs in this Generation.
Generation 1 – Used for medium-lived objects.
Generation 2 – Used for long-lived objects.
Q33. Brief about the managed code.
Ans. It is a code whose execution is managed through runtime(CLR). For the execution of managed code, .NET framework is necessary. In the case of these codes, memory management is performed via garbage collection.
Q34. How do we execute managed code?
Ans. To execute managed code, we can follow these steps:
- Select a language compiler depending on the language of the code.
- Convert the code into Intermediate language using its compiler.
- The IL is then targeted to CLR which transforms the code into native code using JIT.
- Execute Native code.
Q35. Name the different types of assemblies.
Ans. The two different types of assemblies are:
- Private Assembly: Accessible only to the application.
- Shared Assembly: Can be shared by multiple applications.
Q36. Mention the different parts of an Assembly.
Ans. Following are the different parts of an Assembly:
- Manifest – Stores the information about the version of an assembly.
- Type Metadata – Stores the binary information of the program.
- MSIL – Microsoft Intermediate Language code.
- Resources – List of related files.
Q37. List the advantages of Web Services.
Ans. The following are the advantages of Web Services:
- It is stateless and firewall-friendly.
- Easy to create and supported by multiple platforms.
- It can extend its interface and add new methods without affecting the client’s operations.
Q38. What is ADO (ActiveX Data Objects)?
Ans. ADO is an application program used for writing Windows applications. It is also used to get access to a relational or non-relational database from database providers such as Microsoft and others.
Q39. List the fundamental objects in ADO.NET.
Ans. Following are the fundamental objects in ADO.NET:
- DataReader- connected architecture
- DataSet- disconnected architecture
Q40. What is a PE file?
Ans. PE stands for Portable Executable. It is a Microsoft Common Object File Format (COFF) derivative. Windows executable, .EXE or DLL files follow the PE file format. It consists of four parts:
- PE/COFF headers- Contains information regarding .EXE or DLL file.
- CLR header- Contains information about CLR & memory management.
- CLR data- Contains metadata of DDLs and MSIL code generated by compilers.
- Native image section- Contains sections like .data, .rdata, .rsrc, .text etc.
Q41. What is the difference between DLL and EXE?
Ans. .EXE files are single outbound files that cannot be shared with other applications. DLL files are multiple inbound files that are shareable.
Check Out the Best Online Courses
Q42. .NET is an OOP or an AOP framework?
Ans. .NET is an OOP framework as Encapsulation and Inheritance are key features of the Object-Oriented Programming framework.
Q43. What is Just In Time (JIT)?
Ans. Just In Time (JIT) is a CLR compiler responsible for executing .NET programs of different languages. This is done by converting them into machine code. It speeds up the execution of code and supports multiple platforms. There are three types of Just In Time compilers including:
- Pre-JIT compiler: It compiles all source code into the machine code in one compilation cycle, i.e. at the time of application deployment.
- Normal JIT compiler: Source code methods needed at the run-time, are compiled into the machine code and is stored in the cache that is to be called later.
- Econo JIT compiler: Methods required only at the run-time are compiled through this compiler and not stored for future use.
Q44. What is Framework Class Library(FCL)?
Ans. Framework Class Library is used to develop various applications since it offers access to system functionality. It is a collection of reusable types, including interfaces, classes and data types, in the .NET Framework.
Q45. What is caching in .NET?
Ans. Caching is a functionality in the .NET Framework that allows data storage in the memory for rapid access. It is used for performance improvement by making the data available, even when the data source is temporarily unavailable, and it enhances scalability. There are three types of caching in the .NET, including In-memory cache, persistent in-process cache, and distributed cache.
Explore Free Online Courses with Certificates
Q46. What are the different types of caching?
Ans. The different types of caching in .Net are:
- Page caching
- Data caching
- Fragment caching
Q47. Explain the characteristics of .Net core.
Ans. The following are the characteristics of .Net core:
- Speed: It is fast compared to the .NET framework and previous versions.
- Multiple support: This framework is supported by various operating systems such as Linux, macOS and Windows.
- Application development: It is used for developing different types of applications such as IoT, microservices, machine learning, etc.
- Compatibility: It is compatible with Mono, Xamarin and .NET framework via .NET standard. It also supports work with various libraries and web frameworks such as JavaScript and React.
Q48. What are security controls available on ASP.NET?
Ans. There are five security controls available on ASP.NET:
- <asp:Login> Provides login capability that allows users to enter credentials using ID and password fields.
- <asp:LoginView>Provides a range of views based on the selected template.
- <asp:LoginName>Displays the user name who has logged in.
- <asp:PasswordRecovery>: This sends an email to users while resetting the password
- <asp:LoginStatus>Used to check whether the user has been authenticated.
Q49. Explain the difference between value type and reference type.
Ans. The following points explain the difference between value and reference type:
- Value type holds data directly into the memory location. On the other hand, the reference type consists of a pointer with the address of the memory location that holds actual data.
- When you assign a value type variable to another variable, it will copy it directly. When you assign the reference variable to another variable, it does not copy the variable but creates a second copy of the reference.
- Value type stores its content on stack memory, whereas reference type stores content on the heap memory.
This brings us to the end of our blog on dot net interview questions. We hope these Dot Net interview questions will help you ace your upcoming .Net interview.
This is a collection of insightful articles from domain experts in the fields of Cloud Computing, DevOps, AWS, Data Science, Machine Learning, AI, and Natural Language Processing. The range of topics caters to upski... Read Full Bio