.NET framework is a software framework developed by Microsoft that primarily runs on windows, which can be used for building, deploying and running applications that use .NET technologies such as desktop and web applications. So, this article on Top 50 .NET interview questions will help you to brush up your knowledge before the interview.
If you are a fresher or an experienced, this is the right platform for you which will help you to start your preparation for the .NET job roles.
Let’s begin by taking a look at the most frequently asked questions in .NET Interview Questions.
Q-1: What is the .NET framework?
Q-2: What is CLR?
Q-3: What do you know about JIT?
Q-4: What is BCL?
Q-5: What are the different types of constructors in c#?
Q-6: What is caching?
Q-7: What is the application domain?
Q-8: What is a cross-page posting?
Q-9: What are ASP.NET security controls?
Q-10: What are EXE and DLL?
These are some categories based on which I have classified this article,
Beginner .NET Interview Questions
Intermediate .NET Interview Questions
Advanced .NET Interview Questions
Beginner .NET interview Questions
Q-1: What is the .NET framework?
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.
.net logo - .net interview questions - edureka
Q-2: What are the different components of .NET?
Following are the components of .NET
Common Language run-time
Application Domain
Common Type System
.NET Class Library
.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.
Q-4: What is CLR?
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.
Q-5: Explain CLS.
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.
Q-6: What do you know about JIT?
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.
Q-7: Why do we use Response.Output.Write()?
Response.Output.Write() is used to get the formatted output.
Q-8: What is the difference between Response.Redirect and Server.Transfer?
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.
Q-9: What is the difference between managed and unmanaged code?
Managed code Unmanaged code
Managed code is managed by CLR Any code that is not managed by CLR
.NET framework is necessary to execute managed code Independent of .NET framework
CLR manages memory management through garbage collection Own runtime environment for compilation and execution
Q-10: Explain the difference between a class and an object?
Class Object
Class is the definition of an object An object is an instance of a class.
It is a template of the object A class does not become an object unless instantiated
It describes all the methods, properties, etc An object is used to access all those properties from the class.
Q-11: What do you know about boxing and unboxing?
Course Curriculum
Microsoft .NET Framework Certification Training
Course DurationReal-life Case StudiesAssignmentsLifetime Access
Boxing Unboxing
Implicit Explicit
Converting a value type to the type object Extracting the value type from the object
eg : obj myObject = i; eg : i = (int)myObject;
Q-12: Differentiate between constants and read-only variables.
Constants Read-only Variables
Evaluated at compile time Evaluated at run-time
Support only value type variables They can hold the reference type variables
They are used when the value is not changing at compile time Used when the actual value is unknown before the run-time
Cannot be initialized at the time of declaration or in a constructor Can be initialized at the time of declaration or in a constructor
Q-13: What is BCL?
BCL is a base class library of classes, interfaces and value types
It is the foundation of .NET framework applications, components, and controls
Encapsulates a huge number of common functions and make them easily available for the developers
It provides functionality like threading, input/output, security, diagnostics, resources, globalization, etc.
Also serves the purpose of interaction between user and runtime
It also provides namespaces that are used very frequently. for eg: system, system.Activities, etc.
Q-14: What are the different versions of the .NET framework?
Version .NET Framework Visual Studio
C# 1.0 .NET Framework 1.0/1.1 Visual Studio .NET 2002
C# 2.0 .NET Framework 2.0 Visual Studio 2005
C# 3.0 .NET Framework 3.0/3.5 Visual Studio 2008
C# 4.0 .NET Framework 4.0 Visual Studio 2010
C# 5.0 .NET Framework 4.5 Visual Studio 2012/2013
C# 6.0 .NET Framework 4.6 Visual Studio 2013/2015
C# 7.0 .NET CORE Visual Studio 2017
Q-15: What is the difference between namespace and assembly?
An assembly is a physical grouping of logical units whereas namespace groups classes. Also, a namespace can span multiple assemblies as well.
Q-16: What is LINQ?
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.
Q-17: What is MSIL?
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.
Intermediate .NET interview questions
Q-1: Explain the different parts of the assembly.
Following are the different parts of assembly:
Manifest: It has the information about the version of the assembly.
Type Metadata: Contains the binary information of the program
MSIL: Microsoft Intermediate Language Code
Resources: List of related files
Q-2: How do you prevent a class from being inherited?
In C#, we can use the sealed keyword to prevent a class from being inherited.
Q-3: What are the different types of constructors in c#?
Following are the types of constructors in C#:
Default Constructor
Parameterized constructor
Copy Constructor
Static Constructor
Private Constructor
Q-4: What are the different types of assemblies?
There are two types of assemblies:
Private Assembly: It is accessible only to the application, it is installed in the installation directory of the application.
Shared Assembly: It can be shared by multiple applications, it is installed in the GAC.
Q-5: What are MDI and SDI?
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.
Q-6: What is the difference between custom and user control?
Custom Control User Control
Derives from control
Derives from UserControl
Dynamic Layout
Static Layout
Defines a single control
Defines a set of con
It has full toolbox support
Cannot be added to the toolbox
Loosely coupled control
Tightly coupled control
Q-7: What is a garbage collector?
Garbage collector feature in .NET frees the unused code objects in the memory. The memory head is divided into 3 generations:
Generation 0: It stores short-lived objects.
Generation 1: This is for medium-lived objects.
Generation 2: It stores long-lived objects.
Collection of garbage refers to the collection of objects stored in the generations.
Q-8: What is caching?
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.
Following are the types of caching:
Page caching
Data caching
Fragment caching
Q-9: Explain MVC.
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.
mvc .net - .net interview questions- edureka
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.
Programming & Frameworks Training
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.
Q-11: Explain localization and globalization.
Localization Globalization
It means changing the already globalized application to cater to a specific language or culture. Globalization is the process of developing applications to support multiple languages.
Microsoft.Extensions.Localization is used to localize the application content. Existing applications can also be converted to support multiple languages.
Q-12: What is the application domain?
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.
Q-13: What is delegate in .NET?
A delegate in .NET is similar to a function pointer in other programming languages like C or C++. A delegate allows the user to encapsulate the reference of a method in a delegate object. A delegate object can then be passed in a program, which will call the referenced method. We can even use a delegate method to create a custom event in a class.
Q-14: Difference between interface and abstract class in .NET?
Interface Abstract Class
An interface merely declares a contract or behavior that implementing classes should have. An abstract class provides a partial implementation for a functionality that must be implemented by the inheriting entities.
An interface may declare only properties, methods and events with no access modifier. An abstract class declares fields too.
Neither interface nor an abstract class can be instantiated.
Q-15: What is the difference between a stack and a heap?
Stack Heap
Stored value type Stored reference type
A stack is responsible for keeping track of each executing thread and its location. The heap is responsible for keeping track of the more precise objects or data.
Q-16: What are the different validators in ASP.NET?
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.
Advanced .NET Interview Questions
Q-1: What are EXE and DLL?
EXE and DLL are assembly executable modules.
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.
Q-2: What is the difference between function and stored procedure?
Function Stored Procedure
Must return a single value Always used to perform a specific task
It can only have the input parameter It can have both input and output parameters
Exception handling is not possible using a try-catch block Exception handling can be done using a try-catch block
A stored procedure cannot be called from a function A function can be called from a procedure
Q-3: List the events in the page life cycle.
Following are the events in the page life cycle:
Page_PreInit
Page_Init
Page_InitComplete
Page_PreLoad
Page_Load
Page_LoadComplete
Page_PreRender
Render
Q-4: What is the code to send an email from an ASP.NET application?
1
2
3
4
5
6
7
8
mail message = new mail();
message.From = "abc@gmail.com";
message.To = "xyz@gmail.com";
message.Subject = "Test";
message.Body = "hello";
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(message);
Q-5: What are the event handlers that we have for the Global.asax file?
Application Events:
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:
Session_Start, Session_End
Q-6: Explain role-based security.
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.
Q-7: What is cross-page posting?
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.
Q-8: How can we apply themes to an ASP.NET application?
We can use the web.config file to specify the themes
1
2
3
4
5
<cofiguration>
<system.web>
<pages theme="windows"/>
</system.web>
</configuration>
Q-9: Explain passport authentication.
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.
Q-10: What are ASP.NET security controls?
<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: LoginStatus>: Displays if the user is authenticated or not.
<asp: LoginView>: provides various login views depending on the template that has been selected.
<asp: PasswordRecovery>: Emails the users the lost passwords.
Q-11: List all the templates of the Repeater control.
ItemTemplate
AlternatingItemTemplate
SeparatorTemplate
HeaderTemplate
FooterTemplate
Q-12: What is the appSettings section in the web.config file?
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
2
3
4
<em><configuration>
<appsettings>
<add key= "ConnectionString" value="server=local; pwd=password; database=default" />
</appSettings></em>
Q-13: What is MIME?
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.
Course Curriculum
Microsoft .NET Framework Certification Training
Weekday / Weekend Batches
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.
Q-14: What is HTTP Handler?
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.
Following are the default HTTP handlers for ASP.NET:
Page Handler(.aspx): Handles web pages
User Control Handler(.ascx): It handles web user control pages
Web Service Handler(.asmx): Handles web service pages
Trace Handler(trace.axd): It handles trace functionality
Q-15: What are the different types of cookies in ASP.NET?
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.
Q-16: What is the difference between ExecuteScalar and ExecuteNonQuery?
ExecuteScalar ExecuteNonQuery
Returns the output value Does not return any value
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.
No comments:
New comments are not allowed.