REAL TIME Dot Net Interview Question & Answer For [PRACTICE]

REAL TIME Dot Net Interview Question & Answer For [PRACTICE]

Last updated on 05th Jun 2020, Blog, Interview Questions

About author

Aravind (Sr Technical Project Manager )

Delegates in Corresponding Technical Domain with 11+ Years of Experience. Also, He is a Technology Writer for Past 7 Years & Share's this Informative Blogs for us.

(5.0) | 15212 Ratings 6177

.NET is referred to as a software development platform that is used in various languages. It offers interoperability of languages which enables each language to be used in other languages. The dot net structure consists of a class library called FCL. It follows the principle of interoperability, language-independent, type of security, portability, security, memory management, and performance.

1. What is .NET?

Ans:

.NET is a framework for software development. It is just like other software development frameworks like (J2EE). It provides runtime capabilities and a rich set of pre-built functionality in the form of class libraries and APIs. This .NET framework is an environment to build, deploy and run web services and other applications.

The .NET framework contains three main parts:

  • Common Language Runtime
  • Framework classes
  • ASP.NET

2. How many languages are supported by .NET at present time?

Ans:

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.

3. How is it possible for .NET to support many languages?

Ans:

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 functions of another language also.

4. Is ASP.NET different from ASP? If yes, explain how?

Ans:

Yes, ASP.NET is different from ASP. These are the main differences:

  • ASP.NET is developed by Microsoft to create dynamic web applications while ASP (Active Server Pages) is Microsoft’s server side technology used to create web pages.
  • ASP.NET is compiled while ASP is interpreted.
  • ASP uses the technology named ADO while ASP.NET uses ADO.NET.
  • ASP.NET is completely object oriented while ASP is partially object oriented.

5. What is the state management in ASP.NET?

Ans:

State management is a technique that is used to manage a state of an object on different requests. It is very important to manage state in any web application. There are two types of state management systems in ASP.NET.

  • Client side state management
  • Server side state management

6. What is the difference between trace and debug?

Ans:

Debug class is used to debug builds while Trace is used for both debug and release builds.

7. What are the differences between system.stringbuilder and system.string?

Ans:

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.

8. What is the difference between int and int32?

Ans:

 There is no difference between int and int32. System. Int is an alias name for System.Int32 which is a .Net Class.

9. What is the difference between namespace and assembly?

Ans:

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.

Ans:

Following are the main differences between value type and reference type:

  • Value type contains variables while reference type doesn’t contain value directly in its memory.
  • In reference type, memory is allocated in managed heap and in value type memory allocated in stack.
  • Reference type ex-class value type-struct, enumeration

11. What is the difference between session object and application object?

Ans:

The session object is used to maintain the session of each user.

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 an application object the id is maintained for the whole application.

12. What are differences between function and stored procedure in .Net programming language?

Ans:

The difference between function and stored procedure:

  • Function returns only one value but procedure can return one or more than one value.
  • Function can be used in select statements but procedure cannot be used.
  • Function has only input parameters while Procedure can have an input and output parameters.
  • Exceptions can be handled by try-catch blocks in procedures but that is not possible in function.

13. How to retrieve user name in case of Window Authentication?

Ans:

  • System.Environment.UserName

14. What is the difference between a Hash table and Array list?

Ans:

  • Hash table stores data in the form of value pair and name while Array list stores only values.
  • You need to pass a 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 data types while in a Hash table you can store different types of data types. ex. int, string etc.

15. What is the meaning of Immutable?

Ans:

Immutable means once you create a thing, you cannot modify it.

For example: If you want to give new value to old value then it will discard the old value and create a new instance in memory to hold the new value.

16. What are the advantages of using a session?

Ans:

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 the user because the session object is stored on the server.

17. What are the disadvantages of using a session?

Ans:

The disadvantages of using session are:

  • Performance overhead occurs in case of a 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.

18. Can you set the session out time manually?

Ans:

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

19. Explain the boxing and unboxing concept in .Net?

Ans:

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

20. Is it possible to change the index of the primary key on the table?

Ans:

No.

    Subscribe For Free Demo

    21. What is HTTPhandler?

    Ans:

    HttpHandler is a low level request and response API which is made to service incoming Http requests. Every incoming Http request received by ASP.NET is ultimately processed by an instance of a class that implements HttpHandler.

    22. What are the main components of .NET Framework?

    Ans:

    Main components of .Net Framework:

    • Class library
    • Common Language Runtime (CLR)
    • Dynamic Language Runtime (DLR)
    • Application Domains
    • Runtime Hosts
    • Cross-language interoperability
    • Framework security
    • Profiling etc.

    23. What is manifest in .NET Framework?

    Ans:

     Manifest is used to store assembly metadata. It contains all the metadata which are necessary for following things.

    • Version of assembly
    • Security identity
    • Scope of the assembly
    • To resolve references to resources and classes

    24. What are the memory-mapped files?

    Ans:

     Memory-mapped files are used to map the content of a file to the logical address of an application. It makes it possible to run multiple processes 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.

    25. Which method is used to enforce garbage collection in .NET?

    Ans:

    •  System.GC.Collect() method.

    26. What is the difference between dispose() and finalize()?

    Ans:

    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.

    27. Explain the Code Access Security (CAS) in .NET framework.

    Ans:

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

    28. What is Garbage collection?

    Ans:

    Garbage collection is used to prevent memory leaks during execution of programs. There is a low-priority process name as the garbage collector manages the allocation and deallocation of memory for applications. It also checks for the unreferenced variables and objects. If there is any 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 posted back?

    Ans:

     There is a property, named as “IsPostBack” property. You can check it to know that the page is post backed or not.

    30. What is variable and constant in .NET programming language?

    Ans:

    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.

    Variables can be declared by using the following syntax:

    •   <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.

    Constants can be declared by using the following syntax:

    • const int interestRate =10;  

    31. If you want to replace multiple if-else statements in code, which statement will you use?

    Ans:

     In Visual basic, we can use Select-Case statements to replace multiple If-Else statements. In C#, we should use Switch-Case statements to replace multiple If-Else statements.

    32. What are the different types of indexes in .Net?

    Ans:

    There are two types of indexes in .Net:

    Clustered index and non-clustered index

    Course Curriculum

    Get On-Demand .NET Training to Build Your Skills & Advance Your Career

    • Instructor-led Sessions
    • Real-life Case Studies
    • Assignments
    Explore Curriculum

    33. How many types of memories are there in .Net?

    Ans:

    There are two types of memories in .Net

    • Stack memory
    • Heap Memory

    34. Which are the new features added in .NET framework 4.0?

    Ans:

    A list of new features of .NET Framework 4.0:

    • Improved Application Compatibility and Deployment Support
    • Dynamic Language Runtime
    • Managed Extensibility Framework
    • Parallel Programming framework
    • Improved Security Model
    • Networking Improvements
    • Improved Core ASP.NET Services
    • Improvements in WPF 4
    • Improved Entity Framework (EF)
    • Integration between WCF and WF

    35. What are cookies?

    Ans:

    A cookie is a small amount of data created by a 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.

    36. What are the disadvantages of cookies?

    Ans:

    The main disadvantages of cookies are:

    • Cookies can store only string values.
    • Cookies are browser dependent.
    • Cookies are not secure.
    • Cookies can store only a small amount of data.

    37. What is an IL?

    Ans:

    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?

    Ans:

    System.GC.Collect() method is used to enforce garbage collection in .Net.

    39. What are tuples in .Net?

    Ans:

    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.

    40. How many elements a tuple can hold?

    Ans:

    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 parameters or return type of a method.

    41. Which architecture does a Dataset follow?

    Ans:

    A Dataset follows the disconnected data architecture.

    42. How do you check whether a DataReader is closed or opened?

    Ans:

    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.

    43. What are the basic requirements for connection pooling?

    Ans:

    The following two requirements must be fulfilled for connection pooling:

    • There must be multiple processes to share the same connection describing the same parameters and security settings.
    • The connection string must be identical.

    44. Which adapter should be used to get the data from an Access database?

    Ans:

     OleDbDataAdapter is used to get the data from an Access database.

    45. What are the parameters that control most of connection pooling behaviors?

    Ans:

     The following parameters control the connection pooling behavior:

    • Connect Timeout
    • Max Pool Size
    • Min Pool Size
    • Pooling

    46. What do you mean by AutoPostBack?

    Ans:

     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.

    47. Which properties are used to bind a DataGridView control?

    Ans:

     The DataSource property and the DataMember property are used to bind a DataGridView control.

    48. What is ASP.Net?

    Ans:

     It is a framework developed by Microsoft on which we can develop new generation web sites using web forms(aspx), MVC, HTML, Javascript, CSS etc. It is the successor of Microsoft Active Server Pages(ASP). Currently there is ASP.NET 4.0, which is used to develop web sites. There are various page extensions provided by Microsoft that are being used for website development. Eg: aspx, asmx, ascx, ashx, cs, vb, html, XML etc.

    49. What’s the use of Response.Output.Write()?

    Ans:

    We can write formatted output using Response.Output.Write().

    50. In which event of the page cycle is the ViewState available?

    Ans:

    After the Init() and before the Page_Load().

    Course Curriculum

    Learn Practical Oriented Dot Net Training from Real Time Experts

    Weekday / Weekend BatchesSee Batch Details

    51. What is the difference between Server.Transfer and Response.Redirect?

    Ans:

    • In Server.Transfer : page processing transfers from one page to the other page without making a round-trip back to the client’s browser. This provides a faster response with a little less overhead on the server. The clients url history list or current url Server does not update in case of Server.Transfer.
    • Response.Redirect : is used to redirect the user’s browser to another page or site. It performs a trip back to the client where the client’s browser is redirected to the new page. The user’s browser history list is updated to reflect the new address.

    52. From which base class all Web Forms are inherited?

    Ans:

    Page class.

    53. What are the different validators in ASP.NET?

    Ans:

    • Required field Validator
    • Range Validator
    • Compare Validator
    • Custom Validator
    • Regular expression Validator
    • Summary Validator

    54. Which validator control you use if you need to make sure the values in two different controls match?

    Ans:

     Compare Validator control.

    55. What is ViewState?

    Ans:

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

    56. Where the viewstate is stored after the page postback?

    Ans:

    ViewState is stored in a hidden field on the page at the 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.

    57. How long the items in ViewState exist?

    Ans:

     They exist for the life of the current page.

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

    Ans:

    • In-Process
    • 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.

    59. How can you add an event handler?

    Ans:

    Using the Attributes property of server side control.

    e.g:

    • btnSubmit.Attributes.Add(“onMouseOver”,”JavascriptCode();”)

    60. What is caching?

    Ans:

    Caching is a technique used to increase performance by keeping frequently accessed data or files in memory. The request for a cached file/data will be accessed from cache instead of actual location of that file.

    61. What are the different types of caching?

    Ans:

    ASP.NET has 3 kinds of caching :

    • Output Caching,
    • Fragment Caching,
    • Data Caching.

    62. Which type of caching will be used if we want to cache the portion of a page instead of the whole page?

    Ans:

    Fragment Caching: It caches the portion of the page generated by the request. For that, we can create user controls with the below code:

    • <%@ OutputCache Duration=”120″ VaryByParam=”CategoryID;SelectedID”%>

    63. List the events in the page life cycle.

    Ans:

    • Page_PreInit
    • Page_Init
    • Page_InitComplete
    • Page_PreLoad
    • Page_Load
    • Page_LoadComplete
    • Page_PreRender
    • Render

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

    Ans:

    Yes

    65. Is it possible to create a web application with both webforms and mvc?

    Ans:

     Yes. We have to include below mvc assembly references in the web forms application to create hybrid applications.

    • System.Web.Mvc
    • System.Web.Razor
    • System.ComponentModel.DataAnnotations

    66. Can we add code files of different languages in the App_Code folder?

    Ans:

    No. The code files must be in the same language to be kept in the App_code folder.

    67. What is Protected Configuration?

    Ans:

     It is a feature used to secure connection string information.

    68. Write code to send email from an ASP.NET application?

    Ans:

    • MailMessage mailMess = new MailMessage ();
    • mailMess.From = “abc@gmail.com
    •              “;
    • mailMess.To = “xyz@gmail.com”;
    • mailMess.Subject = “Test email”;
    • mailMess.Body = “Hi This is a test mail.”;
    • SmtpMail.SmtpServer = “localhost”;
    • SmtpMail.Send (mailMess);
    • MailMessage and SmtpMail are classes defined System.Web.Mail namespace.

    69. How can we prevent browsers from caching an ASPX page?

    Ans:

    We can SetNoStore on HttpCachePolicy object exposed by the Response object’s Cache property:

    • Response.Cache.SetNoStore ();
    • Response.Write (DateTime.Now.ToLongTimeString ());

    70. What is a good practice to implement validations in an aspx page?

    Ans:

     Client-side validation is the best way to validate data of a web page. It reduces the network traffic and saves server resources.

    Dot Net Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

    71. What are the event handlers that we can have in the Global.asax file?

    Ans:

    Session Events: Session_Start,Session_End

    72. Which protocol is used to call a Web service?

    Ans:

    HTTP Protocol

    73. Can we have multiple web config files for an asp.net application?

    Ans:

    Yes.

    74. What is the difference between web config and machine config?

    Ans:

    Web config file is specific to a web application whereas machine config is specific to a machine or server. There can be multiple web config files into an application where as we can have only one machine config file on a server.

    75. Explain role based security ?

    Ans:

    Role Based Security used to implement security based on roles assigned to user groups in the organization.

    Then we can allow or deny users based on their role in the organization. Windows defines several built-in groups, including Administrators, Users, and Guests.

    • <AUTHORIZATION>< authorization >
    • < allow roles=”Domain_Name\Administrators” / >   < !– Allow Administrators in domain. — >
    • < deny users=”*”  / > < !– Deny anyone else. — >
    • < /authorization >

    76. What is Cross Page Posting?

    Ans:

    When we click the submit button on a web page, the page posts the data to the same page. The technique in which we post the data to different pages is called Cross Page posting. This can be achieved by setting POSTBACKURL property of the button that causes the postback. Findcontrol method of PreviousPage can be used to get the posted values on the page to which the page has been posted.

    77. How can we apply Themes to an asp.net application?

    Ans:

    We can specify the theme in the web.config file. Below is the code example to apply theme:

    • <configuration>
    • <system.web>
    • <pages theme=”Windows7″ />
    • </system.web>
    • </configuration>

    78. What is RedirectPermanent in ASP.Net?

    Ans:

    RedirectPermanent Performs a permanent redirection from the requested URL to the specified URL. Once the redirection is done, it also returns 301 Moved Permanently responses.

    79. What is MVC?

    Ans:

    MVC is a framework used to create web applications. The web application base builds on the Model-View-Controller pattern which separates the application logic from UI, and the input and events from the user will be controlled by the Controller.

    80. Explain the working of passport authentication.

    Ans:

     First of all it checks the 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

    81. What are the advantages of Passport authentication?

    Ans:

    • 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.

    82. What are the asp.net Security Controls?

    Ans:

    • <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

    83. How do you register JavaScript for webcontrols ?

    Ans:

     We can register javascript for controls using <CONTROL -name>Attributes.Add(scriptname,scripttext) method.

    84. In which event are the controls fully loaded?

    Ans:

    • Page load event.
    • Unboxing is reverse of boxing ie. Assigning reference type variable to value type variable.

    86. Differentiate strong typing and weak typing

    Ans:

    In strong typing, the data types of variables are checked at compile time. On the other hand, in case of weak typing the variable data types are checked at runtime. In case of strong typing, there is no chance of compilation error. Scripts use weak typing and hence issues arise at runtime.

    87. How can we force all the validation controls to run?

    Ans:

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

    88. List all templates of the Repeater control.

    Ans:

    • ItemTemplate
    • AlternatingitemTemplate
    • SeparatorTemplate
    • HeaderTemplate
    • FooterTemplate

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

    Ans:

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

    90. What is the appSettings Section in the web.config file?

    Ans:

    The appSettings block in the web config file sets the user-defined values for the whole application.

    For example, in the following code snippet, the specified ConnectionString section is used throughout the project for database connection:

    • <em><configuration>
    • <appSettings>
    • <add key=”ConnectionString” value=”server=local; pwd=password; database=default” />
    • </appSettings></em>

    91. Which data type does the RangeValidator control support?

    Ans:

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

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

    Ans:

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

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

    Ans:

    • System.Globalization
    • System.Resources

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

    Ans:

    • 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.

    95. What is the file extension of web service?

    Ans:

    Web services have file extension .asmx..

    96. What are the components of ADO.NET?

    Ans:

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

    97. What is the difference between ExecuteScalar and ExecuteNonQuery?

    Ans:

     ExecuteScalar returns output value whereas 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.

    99. What is CTS?

    Ans:

    CTS stands for Common Type System. It has a set of rules which state how a data type should be declared, defined and used in the program. It describes the data types that are to be used in the application.

    We can design our own classes and values by following the rules that are present in the CTS. The rules are made so that the data type declared using a programming language can be called by an application that is developed using a different language.

    100. What is CLR?

    Ans:

    CLR stands for Common Language Runtime. It is one of the most important components of the .Net framework. It provides building blocks for many applications.

    An application built using C# gets compiled by its own compiler and is converted into an Intermediate language. This is then targeted to CLR. CLR does various operations like memory management, security checks, assemblies to be loaded and thread management. It provides a secure execution environment for applications.

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free