Categories

Top 50 Dot Net Interview Questions and Answers

The rise in the number of job openings leads to a lot of vacancies and stiff competition to hire the most proficient .NET developers. With these questions, you will gain in-depth knowledge and insight into how to answer the most asked questions in a .NET interview. This guide has been carefully curated, considering many factors and including expert advice from multiple professionals and .NET experts.

1. What is .NET framework?

NET is one of the platforms provided by Microsoft, which is used to build a variety of applications using Windows.

The ability to develop classes, libraries, and APIs and run, debug, and deploy code onto web services and applications form are the key uses of this framework. It supports a lot of languages, and you can work with everything from C# to VB all the way to Perl, and more.

The object-oriented model is championed here in the .NET framework

2. What is the meaning of state management in .NET?

State management, as the name suggests, is used to constantly monitor and maintain the state of objects in the runtime. A web page or a controller is considered to be an object.

There are two types of state management:

Client-side:
It is used to store information on the client’s machine and is formed mostly of reusable and simple objects.

Server-side:
It stores the information on the server and makes it easier to manage and preserve the information on the server.

3. How does managed code execute in the .NET framework?

There are four main steps that include in the execution of the managed code. They are as follows:

1) Choosing a compiler that can execute the code written by a user

2) Conversion of the code into Intermediate Language (IL) using a compiler

3) IL gets pushed to CLR, which converts it into native code using JIT

4) Native code is now executed using the .NET runtime

4. What does CLR stand for in .NET?

CLR stands for Common Language Runtime. It forms to be the most vital component of .NET as it provides the foundation for many applications to run on.

If a user writes an application in C#, it gets compiled and converted to intermediate code. After this, CLR takes up the code and works on it with respect to the following aspects:

1) Memory management

2) Security protocols

3) Libraries for loading

4) Thread management

5. What is CLS?

CLS stands for Common Language Specification in .NET. It is put into place to ensure that the application developer is capable of inter-language operations if required. It is a reusable aspect among all of the .NET compatible languages.

6. What is CTS?

CTS stands for Common Type System. It is a set of structured rules that govern what a data type should be for the corresponding values given by a user. It is used to describe all of the data types that are used in an application that the user is building.

However, you can build your own calls using the rules given by CTS. CTS is mainly provided to cover the variety of languages you can use when working with the .NET framework.

7. What is the meaning of MSIL?

MSIL is the abbreviation of Microsoft Intermediate Language. It is used to provide the instructions required for operations such as memory handling, exception handling, and more. It can also provide instructions to initialize and store values and methods easily.

8. What does JIT stand for in .NET?

JIT is the abbreviation of Just in Time. It is a compiler that is used to convert intermediate code into native code easily.

In .NET, during execution, the code is converted into the native language, also called the byte code. This is processed by the CPU, and the framework helps with the conversion.

9. What are some of the common components of .NET?

There are a lot of components that make up the .NET framework, and some of them are as follows:

1) .NET Class Library

2) .NET Framework

3) Language Runtime

4) Application Domain

5) Profiling

10. What is the difference between managed code and unmanaged code in .NET?

Managed Code

Unmanaged Code

Managed by CLR

Not managed by any entity

Garbage collection is used to manage memory

Runtime environment takes care of the management

The .NET framework is necessary for the execution

Not dependant on the .NET framework to run

11. Is it possible to manually set a timeout for a session in .NET?

Yes, it is possible to manually set a session’s out time. It can easily be done by manipulating the web.config file.

12. What are some of the advantages of using a session?

There are numerous advantages of making use of a session are as mentioned below:

1) It is used to store user data across the span of an application.

2)It is very easy to implement and store any sort of object in the program.

3) Individual entities of user data can be stored separately if required.

4) The session is secure, and objects get stored on the runtime server.

13. What are the constructor types present in C# .NET?

There are five main types of constructor classes in C# as listed below:

1) Copy constructor

2) Default constructor

3) Parameterized constructor

4) Private constructor

5) Static constructor

14. What is the meaning of caching?

Caching is a term used when the data has to be temporarily stored in the memory so that an application can access it quickly rather than looking for it in a hard drive. This speeds up the execution to an exponential pace and helps massively in terms of performance.

There are three types of caching:

1) Data caching

2) Page caching

3) Fragment caching

15. What are some of the components of an assembly in .NET?

There are four main components of an assembly. They are as follows:

Resource:
A collection of related files

MSIL:
The Intermediate Language code

Metadata:
The binary data of a program

Manifest:
A collection of information about the assembly

16. What is an assembly in .NET?

An assembly is the simple collection of all of the logical units present. Logical units are entities that are required to build an application and later deploy the same using the .NET framework. It can be considered as a collection of executables and DLL files.

17. What is the meaning of LINQ?

LINQ is the abbreviated form of Language Integrated Query. It was first brought out in 2008, and it provides users with a lot of extra features when working with the .NET framework. One highlight is that it allows the users to manipulate data without any dependency on its source.

18. What is the difference between an object and a class in .NET?

Object

Class

An instance of a class

The template for creating an object

A class becomes an object after instantiation

The basic scaffolding of an object

Used to access properties from a class

The description of methods and properties

19. What is the difference between system.stringbuilder and system.string in .NET?

system.stringbuilder

system.string

Mutable

Immutable

Supports using append

Cannot use the append keyword

20. What is the difference between a function and a stored procedure in .NET?

Function

Stored Procedure

Can only return one value

Can return any number of values

No support for exception handling using try-catch blocks

Supports the usage of try-catch blocks for exception handling

The argument consists of only one input parameter

Both input and output parameters are present

A function can be called from a stored procedure

The stored procedure cannot be called from a function

Intermediate Interview Questions and Answers

21. What is the use of delegation in .NET?

A delegate works similar to that of a function pointer of other programming languages. It provides a way to encapsulate the reference of a method in an object.

A delegate object can be easily passed to a program after this, and then a method, which was referenced earlier, can be called. Custom events can also be created in the class using a delegate.

22. What are the types of memories supported in the .NET framework?

There are two types of memories present in .NET as listed below:

Stack
Used for static memory allocation

Heap:
Used for dynamic memory allocation

23. What is MVC?

MVC stands for Model-View-Controller. It is an architectural model that is used to build applications in .NET. It serves as the foundation for the creation of applications.

MVC consists of three entities as the name suggests:

Model:
Used to store and pull back data from a database

View:
Used to display the contents of an application

Controllers:
Entities that handle user interaction

24. What are the three generations of garbage collection in .NET?

The three generations of garbage collection are as follows:

Gen 0:
Stores short-lived objects

Gen 1:
Objects moved from Gen 0 live here

Gen 2:
Stores long-lived objects and Gen 1 objects

25. What is the use of GAC in .NET?

GAC is the abbreviation of Global Assembly Cache. GAC is a part of CLR, which is used to store the assemblies that are shared across all of the applications. A user can make use of the Gacutil application to add any file into GAC easily.

26. What is the meaning of garbage collection?

Garbage collection is a process that is used to maintain various aspects of memory to prevent memory leaks during program execution.

An entity called the garbage collector is used to allocate and de-allocate memory as and when required by an application. This is done by performing checks on the references of variables and objects used by the application. If an object is no longer required by the application, the memory is de-allocated and freed up.

27. What is the meaning of CAS in .NET?

CAS stands for Code Access Security. It is vital in the prevention of unauthorized access to programs and resources in the runtime. It can provide limited access to the code to perform only certain operations rather than providing all at a given point in time. CAS forms to be a part of the native .NET security architecture.

28. What are memory-mapped files used for in .NET?

Memory-mapped files in .NET are used to instantiate the contents of a logical file into the address of the application. This helps a user run processes simultaneously on a single machine and have the data shared between processes.

The MemoryMappedFile.CreateFromFiles() function is used to obtain a memory-mapped file object easily.

29. What is the use of manifest in the .NET framework?

Manifest is mainly used to store the metadata of the assembly. It contains a variety of metadata which is required for many things as given below:

1) Assembly version information

2) Security identification

3) Scope checking of the assembly

4) Reference validation of classes

30. What is the meaning of boxing and unboxing in .NET?

Boxing is the process that is used when a user wishes to convert a value type into a reference type directly.

Unboxing is the opposite of boxing, where the reference type is converted back into a value type.

31. What are the requirements needed for connection pooling?

Three main requirements to be fulfilled for connection pooling are as explained below:

1) The presence of an identical connection string for both entities

2) The existence of multiple processes with the same connection parameters

3) The presence of similar security protocols and settings

32. What are the parameters that control connection pooling behaviors in .NET?

There are four main parameters that control connection pooling behaviors in .NET as given below:

1) Connect Timeout

2) Min Pool Size

3) Max Pool Size

4) Pooling

33. What is the meaning of AutoPostBack in .NET?

AutoPostBack is a property in the .NET framework, which provides automatic postback whenever an event starts its execution cycle. To use AutoPostBack, you have to set the property to True.

34. What is the difference between an abstract class and an interface in .NET?

Function

Stored Procedure

Can only return one value

Can return any number of values

No support for exception handling using try-catch blocks

Supports the usage of try-catch blocks for exception handling

The argument consists of only one input parameter

Both input and output parameters are present

A function can be called from a stored procedure

The stored procedure cannot be called from a function

Advanced Interview Questions and Answers

35. How is the status of a DataReader checked in .NET?

The status of a DataReader can be checked easily by using a property called ‘IsClosed.’ It will tell you if the DataReader is closed or opened.

If it is closed, a true value is returned, and if the reader is open, it returns a false value.

36. What are some of the templates that are present in Repeater control?

Many templates are widely used in Repeater control, and some of them are as follows:

1) AlternatingItemTemplate

2) ItemTemplate

3) HeaderTemplate

4) FooterTemplate

5) SeparatorTemplate

37. What is the meaning of role-based security in .NET?

Role-based security, as the name suggests, is a measure implemented in .NET to provide security access based on the roles assigned to users. Examples include the provision of access to users, administrators, and guests.

38. How many elements can a tuple hold in .NET?

A tuple in .NET can hold anywhere up to eight elements. If there are more than eight elements at a time, each of those extra elements gets defined into a separate tuple.

The advantage of tuples in .NET is that they can be used as parameters or return type specifiers.

39. Can themes be applied to ASP.NET applications?

Yes, themes can be applied to ASP.NET applications easily by modifying the following code in the web.config file:

40. Differentiate between the user control and the custom control in the .NET framework.

The status of a DataReader can be checked easily by using a property called ‘IsClosed.’ It will tell you if the DataReader is closed or opened.

If it is closed, a true value is returned, and if the reader is open, it returns a false value.

User Control

Custom Control

Static Layout

Dynamic Layout

No support for the toolbox

Supports the usage of the toolbox

Tightly coupled control access

Loosely coupled control access

Branches from UserControl

Branches from the control group

41. What is the order of the events that take place in a page life cycle?

There are eight events as shown below that take place in an order to successfully render a page:

1) Page_PreInit

2) Page_Init

3) Page_InitComplete

4) Page_PreLoad

5) Page_Load

6) Page_Load

7) Page_LoadComplete

8) Page_PreRender

9) Render

42. What are some of the security controls present in ASP.NET?

There are five security controls present in ASP.NET as shown below:

asp: PasswordRecovery:
Used to send an email to a user upon performing a password reset operation

asp: Login:
Gives the provisions of login controls with ID and password fields for users to login via credentials

asp: LoginName
Used to display the name of the user who has logged into the system

asp: LoginStatus
Used to denote the authentication flag of the user who has logged in

asp: LoginView
Used to provide a variety of views based on themes upon user login

43. What are the types of cookies available in ASP.NET?

There are two types of cookies available in ASP.NET as shown below:

Session cookies:
Present on the client machine and valid only for single sessions

Persistent cookies:
Present on the user machine and has a specific period denoting its expiry

44. What is the use of MIME in .NET?

MIME is the short form of Multipurpose Internet Mail Extensions. It is an add-on to the existing email protocols that lets you exchange files over emails easily.

During a web transmission, servers have the ability to add in a MIME header to the beginning to denote that it is a MIME transaction.

45. What do you mean by cross-page posting?

Consider the situation where you press the submit button on a webpage. Here, the data is stored on the same page. However, if the data has to be stored on a different page and linked to the current one, it would be called a cross-page post.

There is a property called PostBackUrl, which helps you achieve cross-page posting.

46. Have you earned any sort of certification to boost your opportunities as a .NET Developer?

This is a very commonly asked question in .NET interviews today. The interviewer tries to assess how serious you are with your application and career direction toward the .NET field.

It adds immense value to possess a certification from a reputable organization to prove to the interviewer that you have learned the concepts thoroughly and have applied the same using industry-level projects, which have provided you with ample experience about using .NET in the real world!

47. What skills should a successful .NET Developer possess?

This question is primarily asked to gauge your understanding of the depths of the role. The following are some of the important domains and skills you should have:

1) NET MVC architecture
2) Database handling
3) Client-side web development
4) .NET core

48. Has your college degree helped you with .NET development in any way?

The interviewer asks this to assess if you have had any experience learning .NET development in your degree course. Do explain about it if you have come across or used the subject, and it would add a lot of value if you talk about how you plan to use that learning in the coming days after being recruited.

49. Can you rate yourself on a scale of 1–10 depending on your proficiency in .NET?

Here, the interviewer wants to know your understanding of the subject and the proficiency with which you can handle tasks and solve problems. Make sure to retrospect and give out an honest answer.

50. Why are you applying for the .NET Developer role in our company?

With this question, the interviewer wants to understand your interests, goals, and career prospects in the field of .NET. Make sure to state the reasons why you feel that .NET is the right career for you and how you plan to use it to add value to the firm you just gave the .NET interview for.