Dotnet Interview N Questions
Dotnet Interview N Questions
Explore Curriculum
The .NET framework supports an object-oriented approach that is used for building applications on
windows. It supports various languages like C#, VB, Cobol, Perl, .NET, etc. It has a wide variety of tools
and functionalities like class, library and APIs that are used to build, deploy and run web services and
different applications.
Application Domain
.NET Framework
Profiling
Q-3: What do you know about CTS?
CTS stands for Common Type System. It follows certain rules according to which a data type should be
declared and used in the program code. CTS also describes the data types that are going to be used in
the application. We can even make our own classes and functions following the rules in the CTS, it helps
in calling the data type declared in one program language by other programming languages.
CLR stands for common language run-time, it is an important component of the .NET framework. We
can use CLR as a building block of various applications and provides a secure execution environment for
applications.
Whenever an application written in C# is compiled, the code is converted into an intermediate language.
After this, the code is targeted to CLR which then performs several operations like memory
management, security checks, loading assemblies, and thread management.
Common language specification helps the developers to use the components that are inter-language
compatible with certain rules that come with CLS. It then helps in reusing the code in other .NET
compatible languages.
JIT is a compiler which stands for Just In Time. It is used to convert the intermediate code into the native
language. During the execution, the intermediate code is converted into the native language.
Reviews
5(2047)
Reviews
4(53912)
PYTHON SCRIPTING CERTIFICATION TRAINING
Reviews
5(11348)
Reviews
5(483)
Reviews
5(6567)
Reviews
5(4312)
Reviews
5(344)
Reviews
5(9332)
Reviews
5(7078)
Next
Response.Redirect basically redirects the user’s browser to another page or site. The history of the
user’s browser is updated to reflect the new address as well. It also performs a trip back to the client
where the client’s browser is redirected to the new page.
Whereas, Server.Transfer transfers from one page to the other without making any round-trip back to
the client’s browser. The history does not get updated in the case of Server.Transfer.
Managed code is managed by CLR Any code that is not managed by CLR
CLR manages memory management through Own runtime environment for compilation and
garbage collection execution
Boxing Unboxing
Implicit Explicit
Converting a value type to the type object Extracting the value type from the object
Support only value type variables They can hold the reference type variables
They are used when the value is not changing at Used when the actual value is unknown before the
compile time run-time
Cannot be initialized at the time of declaration or Can be initialized at the time of declaration or in a
in a constructor constructor
Encapsulates a huge number of common functions and make them easily available for the
developers
It also provides namespaces that are used very frequently. for eg: system, system.Activities, etc.
An assembly is a physical grouping of logical units whereas namespace groups classes. Also, a
namespace can span multiple assemblies as well.
It is an acronym for Language integrated query which was introduced with visual studio 2008. LINQ is a
set of features that extend query capabilities to the .NET framework language syntax that allows data
manipulation irrespective of the data source. LINQ bridges the gap between the world of objects and the
world of data.
MSIL is the Microsoft Intermediate Language, it provides instructions for calling methods, storing and
initializing values, memory handling, exception handling and so on. All the .NET codes are first compiled
to Intermediate Language.
Q-18: From which base class all web Forms are inherited?
All web forms are inherited from page class.
Want to upskill yourself to get ahead in your career? Check out this video
In C#, we can use the sealed keyword to prevent a class from being inherited.
Parameterized constructor
Copy Constructor
Static Constructor
Private Constructor
MDI( Multiple Document Interface): An MDI lets you open multiple windows, it will have one
parent window and as many child windows. The components are shared from the parent
window like menubar, toolbar, etc.
SDI( Single Document Interface): It opens each document in a separate window. Each window
has its own components like menubar, toolbar, etc. Therefore it is not constrained to the parent
window.
Garbage collector feature in .NET frees the unused code objects in the memory. The memory head is
divided into 3 generations:
Caching simply means storing the data temporarily in the memory so that the data can be accessed from
the memory instead of searching for it in the original location. It increases the efficiency of the
application and also increases its speed.
Page caching
Data caching
Fragment caching
MVC stands for model view controller which is an architecture to build .NET applications.
Model: They are the logical part of any application that handles the object storage and retrieval from
the databases for an application.
View: View handles the UI part of an application. They get the information from the models for their
display.
Controller: They handle the user interactions, figure out the responses for the user input and also
render the view that is required for the user interaction.
Q-10: What is CAS?
CAS stands for code access security, CAS is a part of a security model that prevents unauthorized access
to the resources. It also enables the users to set permissions for the code. CLR then executes the code
depending upon the permissions.
CAS can only be used for managed code. If an assembly uses CAS it is treated as partially trusted.
Although it goes through checks each time an assembly tries to access the resources.
Localization Globalization
It means changing the already globalized application Globalization is the process of developing
to cater to a specific language or culture. applications to support multiple languages.
ASP.NET introduces a concept of application domain or AppDomain which is like a lightweight process
that acts like both container and boundary. The .NET run-time uses the AppDomain as a container for
data and code. The CLR allows multiple .NET applications to run in a single AppDomain.
Stack Heap
A stack is responsible for keeping track of each The heap is responsible for keeping track of the
executing thread and its location. more precise objects or data.
Client-side validation – When the validation takes place on the client-side browser, it is called
client-side validation. Usually, JavaScript is used for client-side validation.
Server-side validation – When the validation takes place on the server then it is called server-
side validation. Server-side validation is considered as a secure form of validation because even
if the user bypasses the client-side validation we can still catch it in server-side validation.
EXE: It is an executable file that runs the application for which it is designed. When we build an
application, an exe file is generated. Therefore the assemblies are loaded directly when we run an exe.
But an exe file cannot be shared with other applications.
DLL: It stands for dynamic link library that consists of code that needs to be hidden. The code is
encapsulated in this library, an application can have many DLLs and can also be shared with other
applications.
It can only have the input parameter It can have both input and output parameters
Exception handling is not possible using a try-catch Exception handling can be done using a try-catch
block block
Page_PreInit
Page_Init
Page_InitComplete
Page_PreLoad
Page_Load
Page_LoadComplete
Page_PreRender
Render
2 message.From = "[email protected]";
3 message.To = "[email protected]";
4 message.Subject = "Test";
5 message.Body = "hello";
6
7 SmtpMail.SmtpServer = "localhost";
8 SmtpMail.Send(message);
Q-5: What are the event handlers that we have for the Global.asax file?
Application Events:
o Application_Start, Application_End, Application_AcquireRequestState,
Application_AuthenticateRequest, Application_AuthorizeRequest,
Application_BeginRequest, Application_Disposed, Application_EndRequest,
Application_Error, Application_PostRequestHandlerExecute,
Application_PreRequestHandlerExecute, Application_PreSendRequestContent,
Application_PreSendRequestHeaders, Application_ReleaseRequestState,
Application_ResolveRequestCache, Application_UpdateRequestCache
Session Events:
o Session_Start, Session_End
Role-based security is used to implement security measures based on the role assigned to the users in
the organization. Then we can authorize users based on their roles in the organization. For example,
windows have role-based access like user, administrators, and guests.
Whenever we click on a submit button on a page, the data is stored on the same page. But if the data is
stored on a different page, it is known as a cross-page posting.
Cross-page posting can be achieved by POSTBACKURL property which causes the postback.
FindControl method can be used to get the values that are posted on this page to which the page has
been posted.
1 <cofiguration>
2 <system.web>
3 <pages theme="windows"/>
4 </system.web>
5 </configuration>
During the passport authentication, it first checks the passport authentication cookie, if the cookie is not
available the application redirects to the passport sign on page. Passport service then authenticates the
details of the user on the sign on page and if they are valid, stores them on the client machine and then
redirects the user to the requested page.
<asp: Login>: Provides a login capability that enables the users to enter their credentials.
<asp: LoginName>: Allows you to display the name of the logged-in user.
<asp: LoginView>: provides various login views depending on the template that has been
selected.
ItemTemplate
AlternatingItemTemplate
SeparatorTemplate
HeaderTemplate
FooterTemplate
If we want to set the user-defined values for the whole applications, we can use the appSettings block in
the web.config file. For example the code below uses the ConnectionString throughout the project for
the database connection:
1 <em><configuration>
2 <appsettings>
4 </appSettings></em>
MIME stands for multipurpose internet mail extensions, it is the extension of the e-mail protocol which
lets users use the protocol to exchange files over the internet.
Servers insert the MIME header at the beginning of the web transmission. Then the clients use this
header to select an appropriate ‘player’ for the type of data that the header indicates. Some of these
players are built into the web browser.
Every request into an ASP.NET application is handled by a specialized component called HTTP handler. It
is the most important component for handling ASP.NET application requests.
It uses different handlers to serve different files. The handler for web page creates the page and control
objects, runs your code and then renders the final HTML.
Session Cookie: It resides on the client machine for a single session until the user logs out.
Persistent Cookie: Resides on the user machine for a period specified for its expiry. It may be an
hour, a month or never.
ExecuteScalar ExecuteNonQuery
Used for fetching a single value Used to execute insert and update statements
Does not return the number of affected rows Returns the number of affected rows.
This brings us to the end of this tutorial. Hope all the questions shared in the article are clear to you.
If you found this article on “.NET Interview Questions” relevant, check out the Edureka .NET Certification
Training, a trusted online learning company with a network of more than 250,000 satisfied learners
spread across the globe. We are here to help you with every step on your journey and come up with a
curriculum that is designed for students and professionals who want to be a .NET developer.
If you come across any questions, feel free to ask all your questions in the comments section of “.NET
Interview Questions” and our team will be glad to answer.
1) What is .NET?
.NET is a framework for software development. It is just like other software development framework like
(J2EE). It provides runtime capabilities and a rich set of pre-built functionality in the form of class library
and API's. This .NET framework is an environment to build, deploy and run web services and other
applications.
o Framework classes
o ASP.NET
The .NET language code is compiled to Microsoft Intermediate Language (MSIL). The generated code is
called managed code. This managed code is run in .NET environment. So after compilation the language
is not a barrier and the code can call or use function of another language also.
Yes, ASP.NET is different from ASP. These are the main differences:
o ASP.NET is developed by Microsoft to create dynamic web applications while ASP (Active Server
Pages) is a Microsoft's server side technology use to create web pages.
o ASP uses the technology named ADO while ASP.NET uses ADO.NET.
State management is a technique that is used to manage a state of an object on different request. It is
very important to manage state in any web application. There are two types of state management
systems in ASP.NET.
Debug class is used to debug builds while Trace is used for both debug and release builds.
There is no difference between int and int32. System. Int is an alias name for System.Int32 which is
a .Net Class.
An assembly is a physical grouping of logical units while namespace groups classes. A namespace can
span multiple assemblies.
10) Explain the differences between value type and reference type.
Following are the main differences between value type and reference type:
o Value type contain variable while reference type doesn't contain value directly in its memory.
o In reference type, memory is allocated in managed heap and in value type memory allocated in
stack.
11) What is the difference between session object and application object?
For example: If a user enters into the application then he will get a session id. If he leaves from the
application then the session id is deleted. If he again enters into the application, he will get a different
session id.
But in the case of application object the id is maintained for whole application.
12) What are differences between function and stored procedure in .Net programming language?
o Function returns only one value but procedure can return one or more than one value.
o Function has only input parameters while Procedure can have an input and output parameters.
o Exceptions can be handled by try catch block in procedures but that is not possible in function.
14) What is the difference between Hash table and Array list?
Hash table stores data in the form of value pair and name while Array list stores only values.
You need to pass name to access value from the Hash table while in Array, you need to pass index
number to access value.
In Array, you can store only similar type of data type while in Hash table you can store different type of
data types. ex. int, string etc.
Immutable means once you create a thing, you cannot modify it.
For example: If you want give new value to old value then it will discard the old value and create new
instance in memory to hold the new value.
o A session stores user states and data to all over the application.
o Session is secure and transparent from user because session object is stored on the server.
o Performance overhead occurs in case of large number of users, because session data is stored in
server memory.
o Overhead involved in serializing and De-Serializing session Data. Because In case of StateServer
and SQLServer session mode we need to serialize the object before store.
No.
HttpHandler is a low level request and response API which is made to service incoming Http request.
Every incoming Http request recieved by ASP.NET is ultimately processed by a instance of a class that
implements HttpHandler.
22) What is .NET Framework and what are the main components of it?
.NET Framework facilitates the developer to develop, run and deploy the applications like console
application, window Forms applications, web applications, web services, window services etc. It also
provides environment to create sharable components to be used in distributed computing architecture.
o Class library
o Application Domains
o Runtime Hosts
o Cross-language interoperability
o Framework security
o Profiling etc.
Manifest is used to store assembly metadata. It contains all the metadata which are necessary for
following things.
o Version of assembly
o Security identity
Memory-mapped files are used to map the content of a file to the logical address of an application. It
makes you able to run multiple process on the same machine to share data with each other. To obtain a
memory mapped file object, you can use the method MemoryMappedFile.CreateFromFiles( ). It
represents a persistent memory-mapped file from a file on disk.
System.GC.Collect() method.
Although Dispose and Finalize both methods are used by CLR to perform garbage collection of runtime
objects of .NET applications but there is a difference between them.
The Finalize method is called automatically by the runtime while the Dispose method is called by the
programmer.
.NET security model is used to prevent unauthorized access of resources and operations and also restrict
the codes to perform particular tasks. Code Access Security is a part of that .NET security.
Garbage collection is used to prevent memory leaks during execution of programs. There is a low-
priority process name as garbage collector manages the allocation and deallocation a memory for
applications. It also checks for the unreferenced variables and objects. If there is ny object which is no
further used by application the Garbage collector frees up the memory from that object.
29) How can you identify that the page is post back?
There is a property, named as "IsPostBack" property. You can check it to know that the page is post
backed or not.
Variable: A variable is a data storage location in the computer memory that contains a value and has a
meaningful name. Every variable is attached to a data type which determines what type of value can be
stored in the variable.
1. <data_type> <variable_name>;
Constant: Constant is also similar to the variable except that the value. Value once assigned to a
constant can't be changed. Constants must be initialized at the same time they are declared.
1. const int interestRate =10;
31) If you want to replace multiple if-else statements in code, which statement will you use?
In Visual basic, we can use Select-Case statement to replace multiple If-Else statement. In C#, we should
use Switch-Case statement to replace multiple If-Else statement.
o Stack memory
o Heap Memory
34) Which are the new features added in .NET framework 4.0?
o Networking Improvements
o Improvements in WPF 4
A cookie is a small amount of data created by server on the client. When a web server creates a cookie,
an additional HTTP header is sent to the browser when a page is served to the browser.
IL stands for Intermediate Language. It is also known as MSIL (Microsoft Intermediate Language) or CIL
(Common Intermediate Language).
All .NET source codes are first compiled to IL. Then, IL is converted to machine code at the point where
the software is installed, or at run-time by a Just-In-Time (JIT) compiler.
38) Which method is used to enforce garbage collection in .NET?
A tuple is a fixed-size collection that can have elements of either same or different data types. The user
must have to specify the size of a tuple at the time of declaration just like arrays.
A tuple can hold up from 1 to 8 elements. In the case of more than 8 elements, then the 8th element
can be defined as another tuple. Tuples can be specified as parameter or return type of a method.
There is a property named "IsClosed" property is used to check whether a DataReader is closed or
opened. This property returns a true value if a Data Reader is closed, otherwise a false value is returned.
o There must be multiple processes to share the same connection describing the same parameters
and security settings.
44) Which adapter should be used to get the data from an Access database?
45) What are the parameters that control most of connection pooling behaviors?
o Connect Timeout
o Pooling
AutoPostBack is a property which is used to postback automatically when an event is raised. You have to
set the AutoPostBack property of the control to True.
The DataSource property and the DataMember property are used to bind a DataGridView control.
1) What is .NET?
.NET is a framework for software development. It is just like other software development framework like
(J2EE). It provides runtime capabilities and a rich set of pre-built functionality in the form of class library
and API's. This .NET framework is an environment to build, deploy and run web services and other
applications.
o Framework classes
o ASP.NET
2) How many languages are supported by .NET at present time?
When .NET was introduced first time, it supports many languages like VB.NET,C#,COBOL, and Perl etc. At
present time it supports almost 44 languages.
The .NET language code is compiled to Microsoft Intermediate Language (MSIL). The generated code is
called managed code. This managed code is run in .NET environment. So after compilation the language
is not a barrier and the code can call or use function of another language also.
Yes, ASP.NET is different from ASP. These are the main differences:
o ASP.NET is developed by Microsoft to create dynamic web applications while ASP (Active Server
Pages) is a Microsoft's server side technology use to create web pages.
o ASP uses the technology named ADO while ASP.NET uses ADO.NET.
State management is a technique that is used to manage a state of an object on different request. It is
very important to manage state in any web application. There are two types of state management
systems in ASP.NET.
Debug class is used to debug builds while Trace is used for both debug and release builds.
There is no difference between int and int32. System. Int is an alias name for System.Int32 which is
a .Net Class.
An assembly is a physical grouping of logical units while namespace groups classes. A namespace can
span multiple assemblies.
10) Explain the differences between value type and reference type.
Following are the main differences between value type and reference type:
o Value type contain variable while reference type doesn't contain value directly in its memory.
o In reference type, memory is allocated in managed heap and in value type memory allocated in
stack.
11) What is the difference between session object and application object?
For example: If a user enters into the application then he will get a session id. If he leaves from the
application then the session id is deleted. If he again enters into the application, he will get a different
session id.
But in the case of application object the id is maintained for whole application.
12) What are differences between function and stored procedure in .Net programming language?
o Function returns only one value but procedure can return one or more than one value.
o Function has only input parameters while Procedure can have an input and output parameters.
o Exceptions can be handled by try catch block in procedures but that is not possible in function.
13) How to retrieve user name in case of Window Authentication?
System.Environment.UserName
14) What is the difference between Hash table and Array list?
Hash table stores data in the form of value pair and name while Array list stores only values.
You need to pass name to access value from the Hash table while in Array, you need to pass index
number to access value.
In Array, you can store only similar type of data type while in Hash table you can store different type of
data types. ex. int, string etc.
Immutable means once you create a thing, you cannot modify it.
For example: If you want give new value to old value then it will discard the old value and create new
instance in memory to hold the new value.
o A session stores user states and data to all over the application.
o Session is secure and transparent from user because session object is stored on the server.
o Performance overhead occurs in case of large number of users, because session data is stored in
server memory.
o Overhead involved in serializing and De-Serializing session Data. Because In case of StateServer
and SQLServer session mode we need to serialize the object before store.
18) Can you set the session out time manually?
No.
HttpHandler is a low level request and response API which is made to service incoming Http request.
Every incoming Http request recieved by ASP.NET is ultimately processed by a instance of a class that
implements HttpHandler.
22) What is .NET Framework and what are the main components of it?
.NET Framework facilitates the developer to develop, run and deploy the applications like console
application, window Forms applications, web applications, web services, window services etc. It also
provides environment to create sharable components to be used in distributed computing architecture.
o Class library
o Application Domains
o Runtime Hosts
o Cross-language interoperability
o Framework security
o Profiling etc.
o Version of assembly
o Security identity
Memory-mapped files are used to map the content of a file to the logical address of an application. It
makes you able to run multiple process on the same machine to share data with each other. To obtain a
memory mapped file object, you can use the method MemoryMappedFile.CreateFromFiles( ). It
represents a persistent memory-mapped file from a file on disk.
System.GC.Collect() method.
Although Dispose and Finalize both methods are used by CLR to perform garbage collection of runtime
objects of .NET applications but there is a difference between them.
The Finalize method is called automatically by the runtime while the Dispose method is called by the
programmer.
.NET security model is used to prevent unauthorized access of resources and operations and also restrict
the codes to perform particular tasks. Code Access Security is a part of that .NET security.
Garbage collection is used to prevent memory leaks during execution of programs. There is a low-
priority process name as garbage collector manages the allocation and deallocation a memory for
applications. It also checks for the unreferenced variables and objects. If there is ny object which is no
further used by application the Garbage collector frees up the memory from that object.
29) How can you identify that the page is post back?
There is a property, named as "IsPostBack" property. You can check it to know that the page is post
backed or not.
Variable: A variable is a data storage location in the computer memory that contains a value and has a
meaningful name. Every variable is attached to a data type which determines what type of value can be
stored in the variable.
1. <data_type> <variable_name>;
Constant: Constant is also similar to the variable except that the value. Value once assigned to a
constant can't be changed. Constants must be initialized at the same time they are declared.
1. const int interestRate =10;
31) If you want to replace multiple if-else statements in code, which statement will you use?
In Visual basic, we can use Select-Case statement to replace multiple If-Else statement. In C#, we should
use Switch-Case statement to replace multiple If-Else statement.
o Stack memory
o Heap Memory
34) Which are the new features added in .NET framework 4.0?
o Networking Improvements
o Improvements in WPF 4
A cookie is a small amount of data created by server on the client. When a web server creates a cookie,
an additional HTTP header is sent to the browser when a page is served to the browser.
IL stands for Intermediate Language. It is also known as MSIL (Microsoft Intermediate Language) or CIL
(Common Intermediate Language).
All .NET source codes are first compiled to IL. Then, IL is converted to machine code at the point where
the software is installed, or at run-time by a Just-In-Time (JIT) compiler.
38) Which method is used to enforce garbage collection in .NET?
A tuple is a fixed-size collection that can have elements of either same or different data types. The user
must have to specify the size of a tuple at the time of declaration just like arrays.
A tuple can hold up from 1 to 8 elements. In the case of more than 8 elements, then the 8th element
can be defined as another tuple. Tuples can be specified as parameter or return type of a method.
There is a property named "IsClosed" property is used to check whether a DataReader is closed or
opened. This property returns a true value if a Data Reader is closed, otherwise a false value is returned.
o There must be multiple processes to share the same connection describing the same parameters
and security settings.
44) Which adapter should be used to get the data from an Access database?
45) What are the parameters that control most of connection pooling behaviors?
o Connect Timeout
o Pooling
AutoPostBack is a property which is used to postback automatically when an event is raised. You have to
set the AutoPostBack property of the control to True.
The DataSource property and the DataMember property are used to bind a DataGridView control.