Top 80 .NET Interview Questions & Answers

Are you planning to attend a Dotnet interview? Do you have a DotNet interview scheduled? Or Do you want to be a .Net developer? Then you are on the right page. We have researched on .Net and noted the most frequently asked .Net Interview Questions and Answers. 

Let us have a quick introduction about .Net. What is .Net? A .Net framework is a software developed by Microsoft to run primarily on Microsoft windows. An extensive class library called Framework class library is included. .Net also provides language interoperability across several other programmings.

Contents show

Top 80 .Net interview questions and answers

1. Can you explain the concept of inheritance and how it works in .NET?

Inheritance is a concept of object-oriented Programming language(OOPS). It allows you to define a base class that provides a specific functionality, and it will enable other derived classes to inherit the base class or override the base class. One of the vital features of inheritance is the ability to reuse the code. The same goes with .Net. .Net frameworks allow inheritance.

2.  Explain .NET web service?

A .Net web service is defined as a software program intended to use XML to exchange information with other software through standard internet protocols. In simple terms, web services provide a path to interact with objects over the internet.

3. Can you differentiate between a stack and a queue?

It is based on the LIFO principle, i.e., Last In First Out.It is based on the FIFP principle, i.r, First in First Out.
Insertion and deletion take place from only the top end.Insertion and deletion take place from both ends.
Insert operations in the stack are called push operations.Insert operations in the queue are called enqueue operations.
Deleting operation in the stack is called a pop operation.Deleting an operation in a queue is called a dequeue operation.

4.  What do the terms boxing and unboxing mean? Explain?

Boxing is a mechanism of converting a value type to an object type or any interface type. When a CLR(Common Language Runtime) boxes a value type, the value inside the system is wrapped.

Unboxing is a process of extracting the value type from an object type.

5.  Can you differentiate between an abstract class and an interface?

Abstract classInterfaceAn abstract class is said to have both abstract and non-abstract methods.The interface can have only abstract methods.
It does not support multiple inheritances.It supports multiple inheritances.
The keyword abstract is used to specify or declare an abstract class, The interface keyword is used to declare an interface class.
The keyword ‘extends’ has to be used to extend an abstract class, The keyword ‘Implements’ has to be used to extend an interface class.

6. Can you explain the main difference between managed and unmanaged code?

Managed codeUnmanaged code
CLR executes managed code.CLR stands for Common Language Runtime.The OS directly executes unmanaged code.
Managed code provides security to the application written in the .Net framework.Unmanaged code does not provide any security to the applications.
Managed code does not provide low-level access to the programmer.Unmanaged code provides low-level access to the programmer.

7.  Name some characteristics of .NET Core?

.Net Interview Questions and Answers

Key characteristics of .Net Core are:

  1. It is open-source.
  2. It is flexible.
  3. It is lightweight, fast, and user-friendly.
  4. It is sharable.
  5. It has scope for future software development.
  6. .Net Core is a cross-platform

8. What is included in .NET Core? Explain?

The .Net Core includes the following components:

  1. It includes .NET CLI, the command-line tool used for local development, and continuous integration tips.
  2. It includes a .NET driver to run framework-dependent apps.
  3. It includes MS BUILD build engine.
  4. It includes Roslyn and F# language compilers.
  5. It includes .Net runtime and desktop runtime.
  6. It includes runtime libraries.

9. Name the three common acronyms used in .NET and what do they stand for?

The three acronyms used in .Net are:

  1. IL → Intermediate Language.
  2. CIL–>Common Intermediate Language.
  3. CLI–>Common Language Infrastructure.

 .Net Interview questions and answers

10.  Explain the JIT compiler?

Just In Time compiler, known as JIT, is a part of CLR(Common Language Runtime) in .Net, which aids in managing the execution of .Net programs irrespective of the .Net programming language. JIT is responsible for converting MSIL(Microsoft Intermediate language) or CIL into machine code.

11. What Is Kestrel? Explain?

Kestrel is defined as a Cross-platform web Server for ASP.NET Core. It is a web server that is included and enabled by default in .Net Core template projects.

12. Can you differentiate between .NET Core and Mono?

.Net CoreMono
It is a cross-platform DotNet framework for building cloud-based web applications.It quickly creates cross-platform applications part of the DotNet foundation.
It is an open-source web framework.It is an open-source implementation of DotNetfoundation.

13. Can you tell me how many languages are supported by .NET at the present time?

.Net supports more than 60 programming languages, where 11 programming languages out of them are designed and developed by Microsoft.

14. Differentiate between trace and debug?

Trace. Write line statements is used with tracing.Debug. Write line statement is used for tracing.
It works in debug mode and release mode.It works only in debug mode.
It is used during the testing phase.It is used during the debugging phase.

15. Can you describe the garbage collection process?

Garbage collection (GC) is the feature of the .Net framework. The GC(Garbage collection)manages your application’s release and allocation of memory. Whenever you create a new object, the CLR allocates the memory for the item from the heap. Now the Garbage collection has to free up the space allocated to the object when it is unused.

16. Can you differentiate between namespace and assembly?

The namespace is responsible for logical code grouping.Assembly is responsible for physical code grouping.
It is used for the logical organization of the classes.It contains metadata of the module types and other elements.
Any other language targeting can use it .netOther languages cannot use it.

17. Differentiate between int and int32?

Int is a primitive data type.Int32 is an FCL type.
It is a value type, and it translates to int32 during compilation.It is also a value type.

18. Can you differentiate between value type and reference type?

Value typeReference type
It stores its content in the memory allocated on the stack.Here the address of the reference object is stored instead of value.
Only a single space in memory is allocated.They are stored in the memory area called the heap.
Examples: Predefined datatypes, enums, and structuresExamples: Classes, arrays, interfaces 

19. Can you differentiate between “systems.StringBuilder” and “system. String”?

system.StringBuildersystem. String
It is mutable.It is immutable.
It is a fixed length.It is a variable length.
It is more efficient.It is not as efficient as string builder.

 .Net Interview questions and answers

20. Explain the difference between Hashtable and Array lists?

HashtableArray Lists
It is a collection of objects where the values are stored on a key basis.It is a collection of objects where values are stored on an index basis.
Fetching values from hashtable is faster.Fetching values from array lists is slower.
It is used to maintain massive data.Array lists are not the best choice when it comes to storing massive data.

21. What is the meaning of Immutable? Explain?

Immutable means the value that is assigned to a string object is never changed.

22. Can you explain the advantages of the session?

Advantages of session:

  1. The session helps us to maintain data and state throughout the application.
  2. Sessions are easy to implement and can store any object type.
  3. Sessions store the client data separately.
  4. It is secured and transparent from the user.

23. Explain cookies?

.Net cookies are used to store user-specific information. The information stored is used by the web application whenever the user visits the site.

24. What are tuples in .Net? Explain?

In the .Net framework, a tuple is defined as a data structure that contains a sequence of elements of different data types. The data elements include strings, integers, characters, or other data types.

25. Can you explain MSIL?

MSIL means Microsoft Intermediate language. It is a programming language, later standardized as Common Intermediate Language. It is a set of instructions that is independent of the platform and is generated by a language-specific compiler from the source code.

26. Can you differentiate between an object and a class in .NET?

An object is an instance of a class.A class is a blueprint from which an instance is created.
It acts like a variable of the class.It is used to bind data and methods together.
They have a physical existence.They have logical existence.
The object creates a memory space.Class does not create any memory space.

27. What is the meaning of caching? Explain? 

Cashing in .Net is a technique of storing frequently used data or information in memory. Whenever the same data or information is needed, it can directly retrieve from the memory.

28. What is CLR in .Net?

CLR in .Net stands for Common Language Runtime. It is a virtual machine component of the Microsoft .Net Framework, which manages the execution of the .Net programs.

29. What is MSIL in .Net?

MSIL, i.e., Microsoft Intermediate Language, the compiler converts the source code into MSIL(Microsoft Intermediate Language) during the compilation. It is a set of independent CPU instructions which can be efficiently converted into native code.

30. What is the page life cycle in .Net?

When a .Net page runs, the page goes through a life cycle, where it performs a set of processing steps, which includes initialization, restoring, running event handlers, and maintaining states.

.Net Interview questions and answers

31. Can you explain the use of manifest in the .NET framework?

Manifest in .Net is an XML file, which specifies and identifies the shared and private side-by-side assemblies that an application should bind at the run time.

32. Can you explain what is the use of GAC in .NET?

GAC, i.e., Global Assembly Cache, is a Windows directory folder to store the .Net assemblies and are designated to be shared by all the executing applications on the system. In simple terms, assemblies are shared among multiple applications, on a machine, by registering to GAC.

33. Can you explain how many elements a tuple can hold in .NET?

The maximum number of elements that a tuple can allow is eight elements. If the number exceeds, then the compiler throws an error.

34. Name the three generations of garbage collection in .NET?

The three generations of garbage collections in .net are:

  1. Generation 0
  2. Generation 1
  3. Generation 2.

35. Name the types of memories supported in the .NET framework?

Memories supported in .Net are:

  1. Stack memory
  2. Heap memory.

36. Explain the difference between a function and stored procedure in .NET?

The function and stored procedure differences:

FunctionStored Procedure
With the given input, the function is used to calculate the results.It is used to perform a specific task in order.
DML statements cannot be executed.DML statements can be executed.
It does not support try-catch.It supports try-catch.
It can be called within an SQL query.It cannot be called within an SQL query.

37. Can you name the constructor types present in C# .NET?

Constructor types:

  1. Default constructor.
  2. Static constructor.
  3. Private constructor.
  4. Copy constructor.
  5. Parametrized constructor.

38. What is LINQ?

LINQ, i.e., Language Integrated Query, is a name given to the set of technologies that are based on the integration query capabilities into the c# language directly. It is used to retrieve data from different sources.

39. Explain cross-page posting?

Cross-page posting is useful when you want to post data to another or different page, and you do not want to reload the current page. In simple terms, the cross-page posting is defined as submitting a form to a separate page.

.Net interview question and answers

40. Name the types of cookies available in ASP.NET?

  1. Persistent cookies.
  2. Non-Persistent cookies.

41. Name some of the templates that are present in Repeater control?

  1. Header Template.
  2. Item Template.
  3. Separator Template.
  4. AlternatingItem Template.
  5. Footer Template.

42. Describe the Global.asax file?

Global. Asax in .Net is an optional file used for handling high-level application events, like Application-start, Application-end,  Session-end, Session Start, etc. The Global. asax file is stored in the root directory of the .Net application.

43. Can you explain Server controls in ASP.NET?

Server controls are defined as small building blocks of the GUI(Graphical User Interface), including buttons, checkboxes, labels, etc.

ASP.NET Server controls are classified as:

  1. Validation controls.
  2. Data source controls.
  3. Data view controls.
  4. Rich controls.
  5. Navigation controls.
  6. Master controls.

44. Explain web controls in ASP.NET?

Web controls are the controls used for structural controls such as security, data validation, creating master pages, and data manipulation.

ASP.NET has five web control.

  1. HTML controls
  2. HTML Server controls
  3. ASP.NET Server controls
  4. ASP.NET Ajax Server controls
  5. User controls and custom controls

45. Explain the function of the LoginStatus Control?

Login status control is a control used to display the login and logout links based on the current users’ login status. 

46. Explain fragment caching?

Fragment caching is a caching type, which refers to the caching of individual user controls within a web form. It is useful when you want to cache only a subset of the page.

47. Explain RedirectPermanent in ASP.Net?

RedirectPermanent is a method in ASP.NET that performs the same redirect as the response method. RedirectPermanent() is a new method of Response().

48.  Explain the difference Between Server. Transfer and Response. Redirect?

It is used to transfer a web user from one page to a different page.It is also used to transfer a web user from one page to another page.
It just tells the browser to visit another page.It helps to reduce Server requests.

49. Describe a web service?

A web service is a tiny piece of software that makes it available over the internet, and it makes use of a standard XML messaging system. Here the XML is used to encode all the information to a web service.

.Net Interview questions and answers

50. Explain “PostBack” in ASP.NET?

PostBack in ASP.NET is a name given to the process that submits an ASP.NET page to the Server. For processing. PostBack is performed to check specific credentials of the page, such as user name and password verification.

51. Explain a Repeater Control?

Repeater control is a web control that allows the user to split mark-up tags across the templates.

52. Explain the HTML Server controls in ASP.NET?

HTML Server controls are standard HTML controls used to enable Server-side processing.

Few HTML Server controls are listed below:

  1. HTMLHead.
  2. HTMLInputButton.
  3. HTMLInputImage.
  4. HTMLInputPassword.
  5. HTMLText.
  6. HTMLInput Reset.

53. Name the different Validators in ASP.NET?

  1. RequiredFieldValidator.
  2. RangeValidator.
  3. CompareValidator.
  4. RegularExpressionValidator.
  5. CustomValidator.
  6. ValidationSummary.

.Net Interview questions and answers

54. Explain state management in ASP.NET?

Answer: State management in ASP.NET is used to preserve the state control and object in an application because .NET web applications are stateless.

There are two state management methods in ASP.NET.

  1. Client-side state management.
  2. Server-side state management.

55. What is a Common Type system (CTS) in .Net?

Answer: Common Type system is a .NET standard that specifies how definition types and specific value types are represented in the computer memory. It is designed to allow different programming languages to share information easily.

56. Can you explain CAS(Code Access Security)?

Answer: Code access security(CAS) is a Microsoft .NET framework used to prevent untrusted or illegitimate code from performing privileged actions.

57. Explain web. Config file in appSettings?

Answer: App setting is used to store a string or other values, which is found on the web—config file of the ASP.NET website project. The web. config file is read by the IIS and the ASP.NET Core module for its configuration.

58. Explain Model View Controller framework?

Answer: MVC is an architecture pattern that divides an application into three components, namely,

  1. The Model- It is related to all logical data that the user works with.
  2. The View.- It is used for the UI logic of the application.
  3. The Controller.- It is an interface between model and view components.

59. Explain ASp.NET web forms?

Web forms in ASP.Net Is a web application framework, and it is one of the programming models supported by ASP.NET technology.

60. Name the types of caching in .Net?

Types of caching:

  1. Page-level caching.
  2. Page fragment caching.
  3. Data caching.

.Net Interview questions and answers

61. Name the security controls in .Net?

Few security controls supported by .Net are:

  1. <asp:Login>
  2. <asp:LoginName>
  3. <asp:LoginStatus>
  4. <asp:LoginView>
  5. <asp:PasswordRecovery>

62. Explain Razor in ASP.NET?

Razor is defined as an ASP.NET programming syntax, which is used to create dynamic web pages with the help of c# or VB.Net programming languages.

63. Explain MIME?

A multi-purpose mail extension is an extension of the email protocol that lets users use the protocol to exchange files over the internet.

64. Name the different types of assemblies?

The types of assemblies are:

  1. Private Assembly.
  2. Shares Assembly.

65. Can you list the events in the page life cycle?

Events in the page life cycle are listed below.

  1. Page_PreInit
  2. Page_Init
  3. Page_InitComplete
  4. Page_PreLoad
  5. Page_Load
  6. Page_LoadComplete
  7. Page_PreRender
  8. Render

66. Can you explain passport authentication?

Passport authentication in ASP.NET lets the user use Microsoft’s passport service to authenticate the application’s users. Passport makes use of encoded cookies to identify authenticated users.

67. Can you explain the disadvantages of using a session?

Disadvantages of the session are:

  1. The decrease in the performance,  because of the increase in the number of users.
  2. Cost is involved in serializing and deserializing session data.

68. Can you change the index of a primary key on a table?

The answer is No. You cannot change the index of the primary key of the table.

69. Define memory-mapped files?

Memory-mapped files map the content or data of the file to the logical address of the application. Memory maps enable you to run multiple processes on the same machine by sharing data with each other. The method MemoryMappedFile.CreateFromFiles( ) to obtain a memory-mapped object.

70. Name the different types of indexes in .Net?

The two types of indexes in .Net are:

  1. Clustered Index.
  2. Non clustered index.

71. What is IL in .Net?

IL in .Net means Intermediate language., All the DotNet source code is first compiled to IL(Intermediate Language), later IL is converted into machine language.

72. Name the method used to enforce garbage collection in .NET?

The method used to enforce garbage collection in the system. GC.Collect().

73. Name the architecture that the dataset followed?

A dataset follows disconnected data architecture.

74. Name the adapter used to get the data from an Access database?

The adapter used to get the data from an access database is OleDbDataAdapter.

75. Explain ASP.NET?

ASP.NET is defined as an open-source, Server-side web application framework to give dynamic web pages. Microsoft develops it.

76. Name the different parts of assembly?

The different parts of an assembly are:

  1. Manifest- It contains information about the assembly version.
  2. Type Metadata- It contains binary information
  3. MSIL 
  4. Resources- It gives a list of related files.

77. Can you tell us whether it is possible to manually set a timeout for a session in .NET?

The answer is yes. It is possible to manually set a timeout for a session in .NET

78. Name the parameters that control connection pooling behaviors in .NET?

The parameters are:

  1. Connect timeout.
  2. Min pool size.
  3. Max Pool size.
  4. Pooling.

79. How can you check the status of a DataReader in .NET?

By using the property “IsClosed,” the status of the DataReader can be checked.

80. What is a delegate in .NET? Explain?

Delegate is a mechanism where it allows methods to be passed as parameters. Delegates are used to encapsulate objects. Delegates are used to define callback methods.

Best of luck with your .Net interview, and I hope our .Net Interview questions and answers were of some help to you. If you are looking for a job in the Salesforce area, then you can check out our Salesforce Interview Questions.

Recommended Articles