Java, J2EE & SOA Certification Training
- 37k Enrolled Learners
- Live Class
.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.
These are some categories based on which I have classified this article,
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.
Q-2: What are the different components of .NET?
Following are the components of .NET
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.
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.
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 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?
|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.
|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-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.
Q-1: Explain the different parts of the assembly.
Following are the different parts of assembly:
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.
Following are the types of constructors in C#:
Q-4: What are the different types of assemblies?
There are two types of assemblies:
Q-5: What are MDI and SDI?
Q-6: What is the difference between custom and user control?
|Custom Control||User Control|
Derives from control
Derives from UserControl
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:
Collection of garbage refers to the collection of objects stored in the 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.
Following are the types of 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.
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.
Q-11: Explain localization and 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.|
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?
|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?
|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?
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 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?
|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:
Q-4: What is the code to send an email from an ASP.NET application?
mail message = new mail(); message.From = "firstname.lastname@example.org"; message.To = "email@example.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?
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.
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
<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.
<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.
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:
<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.
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?
|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.