NET INTERVIEW QUESTIONS AND ANSWERS

.NET INTERVIEW QUESTIONS AND ANSWERS 2021

Q1: What is the .NET framework? 

Answer : 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? 

Answer: 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? 

Answer: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? 

Answer: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. 

Answer: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? 

Answer :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()? 

Answer :Response.Output.Write() is used to get the formatted output. 

 

Q-8: What is the difference between Response.Redirect and Server.Transfer? 

Answer :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. 

 

Q-9: What is the difference between namespace and assembly? 

Answer :An assembly is a physical grouping of logical units whereas namespace groups classes. Also, a namespace can span multiple assemblies as well. 

 

Q-10: What is LINQ? 

Answer :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? 

Answer :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? 

Answer :All web forms are inherited from page class. 

 

 

 

Q-19 What is an Assembly? What are the different types of Assemblies? 

Answer : An Assembly is a collection of logical units. Logical units refer to the types and resources which are required to build an application and deploy them using the .Net framework. The CLR uses this information for type implementations. Basically, Assembly is a collection of Exe and Dlls. It is portable and executable. 

There are two types of Assemblies, Private and Shared. 

Private Assembly, as the name itself suggests, it is accessible only to the application. It is installed in the installation directory of the Application. 

A  Shared assembly can be shared by multiple applications. It is installed in the GAC. 

 

Q-20 Explain the different parts of an Assembly. 

Answer The different parts of an Assembly are: 

  • Manifest – It contains the information about the version of an assembly. It is also called as assembly metadata. 
  • Type Metadata – Binary information of the program. 
  • MSIL – Microsoft Intermediate Language code. 
  • Resources – List of related files. 

 

Q 21 What is an EXE and a DLL? 

Answer : Exe and DLLs are Assembly executable modules. 

Exe is an executable file. This runs the application for which it is designed. An Exe is generated when we build an application. Hence the assemblies are loaded directly when we run an Exe. However, an Exe cannot be shared with the other applications. 

DLL stands for Dynamic Link Library. It is a library that consists of code which needs be hidden. The code is encapsulated inside this library. An Application can consist of many DLLs. These can be shared with the other applications as well. 

Other applications which need to share this DLL need not worry about the code intricacies as long as it is able to call the function on this DLL. 

 

Q 22) What is Caching? 

Ans: Caching means storing data temporarily in the memory so that the application can access the data from the cache instead of looking for its original location. This increases the performance of the application and its speed. System.Runtime.Caching namespace is used for Caching information in .Net. 

Given below are the 3 different types of Caching: 

  • Page Caching 
  • Data Caching 
  • Fragment Caching 

 

Q 23 What is MVC? 

Ans: MVC stands for Model View Controller. It is an architectural model for building the .Net applications. 

Models – Model objects store and retrieve data from the database for an application. They are usually the logical parts of an application that is implemented by the application’s data domain. 

View – These are the components that display the view of the application in the form of UI. The view gets the information from the model objects for their display. They have components like buttons, drop boxes, combo box, etc. 

Controllers – They handle the User Interactions. They are responsible for responding to the user inputs, work with the model objects, and pick a view to be rendered to the user. 

 

Q 24 What is the difference between Function and Stored procedure? 

Answer : 

Stored Procedure: 

  • A Stored procedure is always used to perform a specific task. 
  • It can return zero, one or more value. 
  • It can have both Input and Output Parameters. 
  • Exception handling can be done using a try-catch block. 
  • A function can be called from a Procedure. 

Functions: 

  • Functions must return a single value. 
  • It can only have the input parameter. 
  • Exception handling cannot be done using a try-catch block. 
  • A Stored procedure cannot be called from a function. 

 

Q 25 Explain CAS (Code Access Security). 

Answer: .Net provides a security model that prevents unauthorized access to resources. CAS is a part of that security model. CAS is present in the CLR. It enables the users to set permissions at a granular level for the code. 

 

Q 26 What is GAC? 

Answer : GAC stands for Global Assembly Cache. Whenever CLR gets installed on the machine, GAC comes as a part of it. GAC specifically stores those assemblies which will be shared by many applications. A Developer tool called Gacutil.exe is used to add any file to GAC. 

 

 

 

Q 27 What is meant by Globalization and Localization? 

Answer : Internationalization is the process of designing applications that support multiple languages. This is divided into Localization and Globalization. 

Globalization is nothing but developing applications to support different languages. Existing applications can also be converted to support multiple cultures. 

Whereas Localization means changing the already globalized app to cater to a specific culture or language Microsoft.Extensions.Localization is used for localizing the app content. Some of the other keywords that are used for Localization are IHtmlLocalizerIStringLocalizerIViewLocalizer and so on 

 

Q 28 What is ViewState? 

ViewState is used to retain the state of server-side objects between page post backs. 

 

Q 29  Where the viewstate is stored after the page postback? 

Answer : ViewState is stored in a hidden field on the page at client side. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. 

 

Q 30  How long the items in ViewState exists? 

Answer : They exist for the life of the current page. 

 

Q 31 What are the different Session state management options available in ASP.NET? 

Answer : 

  1. In-Process 
  1. Out-of-Process. 

In-Process stores the session in memory on the web server. 

Out-of-Process Session state management stores data in an external server. The external server may be either a SQL Server or a State Server. All objects stored in session are required to be serializable for Out-of-Process state management. 

List the events in page life cycle. 

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

 

Q32 Can we have a web application running without web.Config file? 

Answer : yes 

 

Q33. Explain the working of passport authentication. 

Answer : First of all it checks passport authentication cookie. If the cookie is not available then the application redirects the user to Passport Sign on page. Passport service authenticates the user details on sign on page and if valid then stores the authenticated cookie on client machine and then redirect the user to requested page 

 

Q34. What are the advantages of Passport authentication? 

Answer : All the websites can be accessed using single login credentials. So no need to remember login credentials for each web site. 

Users can maintain his/ her information in a single location. 

 

Q35. What are the asp.net Security Controls? 

Answer :  

  • <asp:Login>: Provides a standard login capability that allows the users to enter their credentials 
  • <asp:LoginName>: Allows you to display the name of the logged-in user 
  • <asp:LoginStatus>: Displays whether the user is authenticated or not 
  • <asp:LoginView>: Provides various login views depending on the selected template 
  • <asp:PasswordRecovery>: email the users their lost password 

 

Q 36 How we can force all the validation controls to run? 

The Page.Validate() method is used to force all the validation controls to run and to perform validation. 

 

 

 

Q 37. List all templates of the Repeater control. 

Answer : 

  • ItemTemplate 
  • AlternatingltemTemplate 
  • SeparatorTemplate 
  • HeaderTemplate 
  • FooterTemplate 

 

Q38 List the major built-in objects in ASP.NET? 

Answer : 

  • Application 
  • Request 
  • Response 
  • Server 
  • Session 
  • Context 
  • Trace 

 

Q39 Which data type does the RangeValidator control support? 

Answer : The data types supported by the RangeValidator control are Integer, Double, String, Currency, and Date. 

 

Q 40. What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control? 

Answer : In HtmlInputCheckBoxcontrol, multiple item selection is possible whereas in HtmlInputRadioButton controls, we can select only single item from the group of items. 

 

41. Which namespaces are necessary to create a localized application? 

Answer : SSystem.GlobalizationSystem.Resources 

 

Q42 What are the different types of cookies in ASP.NET? 

Answer : Session Cookie – Resides on the client machine for a single session until the user does not log out. 

Persistent Cookie – Resides on a user’s machine for a period specified for its expiry, such as 10 days, one month, and never. 

 

Q 42. What is the file extension of web service? 

Answer : Web services have file extension .asmx.. 

 

Q43. What are the components of ADO.NET? 

Answer :The components of ADO.Net are Dataset, Data Reader, Data Adaptor, Command, connection 

 

Q44. What is the difference between ExecuteScalar and ExecuteNonQuery? 

Answer : ExecuteScalar returns output value where as ExecuteNonQuery does not return any value but the number of rows affected by the query. ExecuteScalar used for fetching a single value and ExecuteNonQuery used to execute Insert and Update statements. 

 

Q 45 What are differences between system.stringbuilder and system.string? 

Answer : The main differences between system.stringbuilder and system.string are: 

  • system.stringbuilder is a mutable while system.string is immutable. 
  • Append keyword is used in system.stringbuilder but not in system.string. 

 

Q46  What is the meaning of Immutable? 

Answer : 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. 

 

 

Q 47 What are the advantages of using session? 

Answer : The advantages of using session are: 

A session stores user states and data to all over the application. 

It is very easy to implement and we can store any kind of object. 

It can store every user data separately. 

Session is secure and transparent from user because session object is stored on the server. 

 

Q 48 What are the disadvantages of using session? 

Answer :The disadvantages of using session are: 

Performance overhead occurs in case of large number of users, because session data is stored in server memory. 

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. 

 

49 Can you set the session out time manually? 

Yes. Session out time can be set manually in web.config. 

 

50 Explain the boxing and unboxing concept in .Net? 

Boxing: Boxing is a process of converting value type into reference type. 

Unboxing: Unboxing is a process of converting reference type to value type.