Best 43 Dot Net Developer Interview Questions

1. Define Overriding?
Answer: Overriding is a concept where a method in a derived class uses the same name, return type, and arguments as a method in its base class. In other words, if the derived class contains its own implementation of the method rather than using the method in the base class, the process is called overriding.

2. Why don’t we have multiple inheritances in .NET?
Answer: There are several reasons for this. In simple words, the efforts are more, benefits are less. Different languages have different implementation requirements of multiple inheritances. So in order to implement multiple inheritances, we need to study the implementation aspects of all the languages that are CLR compliant and then implement a common methodology of implementing it. This is too much of efforts. Moreover, multiple interface inheritance very much covers the benefits that multiple inheritances have.

3. What is an Interface?
Answer: An interface is a standard or contract that contains only the signatures of methods or events. The implementation is done in the class that inherits from this interface. Interfaces are primarily used to set a common standard or contract.

4. What are events and delegates?
Answer: An event is a message sent by a control to notify the occurrence of an action. However, it is not known which object receives the event. For this reason, .NET provides a special type called Delegate which acts as an intermediary between the sender object and receiver object.

5. What is Method Overriding? How to override a function in C#?
Answer: An override method provides a new implementation of a member inherited from a base class. The method overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method.
Use the override modifier to modify a method, a property, an indexer, or an event. You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override.

6. What is an Assembly? Explain different types of Assemblies?
Answer: An assembly is a final deployable unit which can be versioned and secured. The assembly can also be termed as a reusable collection of types and resources which work together as a logical unit of functionalities in .NET. .NET assemblies can be designed as executable (.EXE) or reusable component (.DLL). An assembly contains one or more managed types which can be made accessible to the unit or outside the unit.
Assembly gets divided into four different parts.

  • Manifest.
  • Type Metadata.
  • Intermediate Language.
  • Resources.

Manifest – contains information about the assembly like Version of an assembly, the public key in case the assembly is shared assembly and the culture information. It also contains the security demands to verify this assembly. CLR uses the manifest to load the assembly.
Type Metadata – gives the complete information about the types which are available in the assembly like Class, Structure, Interface, Enum, and the methods, their parameters. The compilers automatically generate this metadata. You can make use of this Type Metadata to dynamically load the types using .NET Reflection.
Intermediate Language – It a code generated by the language-specific compiler. It is also known as Machine independent code which can be compiled on one machine and can be deployed on another. CLR targets this code to JIT to convert it into processor depend on code which can be further executed.
Resources – Assembly can also contain the embedded resources like icons, images, string tables media clips.

7. Microsoft .NET support different types of assemblies?
Answer:

  • Private Assembly – Private Assemblies are the assemblies which are only known to the application to which it has been referenced. By default, the assemblies are always private when you create and reference them. The private assembly gets stored in the application folder which is using the assembly.
    Private assemblies are identified with the help of name of an assembly and version of an assembly. But the versions do not really come into the picture as the referenced assembly is in the same folder of your application.
  • Shared/Global/Public Assembly – Global/Public Assemblies are the assemblies which are shared across multiple applications. These assemblies are installed into Global Assembly Cache which acts as a shared area for all the assemblies.
    Global Assembly is identified with the four-part assembly name – Name of an Assembly, Version of an assembly, and Culture of an Assembly and Public Key Token of an assembly. Global Assembly Cache can contain different versions of an assembly.
    You can install a public/global assembly into Global Assembly Cache [GAC] using GACUTIL.EXE tool.
  • Satellite Assembly – Satellite Assemblies are used to build multi-lingual assemblies for applications. Satellite assemblies contain information about the cultures. Satellite assemblies are used to display the data in multiple languages according to Country/Region.

8. What is MVC?
Answer:
Model-View-Controller (MVC) is a pattern to separate an application into the following three main components:
Model
View
Controller
The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating web applications. The ASP.NET MVC Framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentications. The MVC framework is defined in the System.Web.MVC assembly. It provides full control over HTML, JavaScript, and CSS. It’s the better as well as a recommended approach for large-scale applications where various teams are working together.
MVC
The ASP.NET MVC framework offers the following advantages:
It makes it very easy to manage complexity by dividing an application into the Model, View, and Controller.
It does not use view state or server-based forms.
Full control over HTML, JavaScript, and CSS.
It provides better support for Test-Driven Development (TDD).
It works well for Web applications that are supported by large teams of developers and for web designers who need a high degree of control over the application behavior.
By default support of Facebook and Google Authentication.
It easy to manage a large application to divide into multiple areas.

9. What are Cookies in ASP.NET?
Answer: Cookies are a State Management Technique that can store the values of control after a post-back. Cookies can store user-specific information on the client’s machine-like when the user last visited your site. Cookies are also known by many names, such as HTTP Cookies, Browser Cookies, Web Cookies, Session Cookies and so on. Basically cookies are a small text file sent by the web server and saved by the Web Browser on the client’s machine.

List of properties containing the HttpCookies Class:

Domain: Using these properties we can set the domain of the cookie.
Expires: This property sets the Expiration time of the cookies.
keys: If the cookies have a subkey then it returns True.
Name: Contains the name of the Key.
Path: Contains the Virtual Path to be submitted with the Cookies.
Secured: If the cookies are to be passed in a secure connection then it only returns True.
Value: Contains the value of the cookies.
Limitation of the Cookies

The size of cookies is limited to 4096 bytes.
A total of 20 cookies can be used in a single website.

10. How many languages .NET is supporting now?
Answer:

When .NET was introduced it came with several languages.
VB.NET,
C#,
COBOL
and
Perl, etc.

11. Define a multilingual Web site?
Answer: multilingual Web site serves content in a number of languages. It contains multiple copies for its content and other resources, such as date and time, in different languages.

12. What is IIS? Why is it used?
Answer: Internet Information Services (IIS) is created by Microsoft to provide Internet-based services to ASP.NET Web applications. It makes your computer to work as a Web server and provides the functionality to develop and deploy Web applications on the server. IIS handles the request and response cycle on the Web server. It also offers the services of SMTP and FrontPage server extensions. The SMTP is used to send emails and use FrontPage server extensions to get the dynamic features of IIS, such as form handler.

13. What is a multiple document interface(MDI)?Answer:
A user interface container that enables a user to work with more than one document at a time. E.g. Microsoft Excel.

14. What is the HTML server control in ASP.NET?
Answer: The Microsoft.NET Framework provides a rich set of server-side controls for developing Web applications. You can add these controls to WebForms pages just as you add Windows controls to a form.  Server-side controls are often called server controls or WebForms controls. There are four types of Server controls: HTML server controls. Web server controls, validation control, and user controls.

HTML Server controls
HTML developers must be familiar with old HTML controls, which they use to write GUI applications in HTML. These controls are the same HTML controls; you can run these controls on the server by defining the run at =”server” attribute. These control names start with Html.

Controls Description
HtmlForm Create an HTML form control, used as a place holder of other controls.
HtmlInputText Creates an input text box control used to get input from the user.
HtmltextArea Creates multiline text box control.
HtmlAnchor Creates Web navigation.
HtmlButton Creates a button control.
HtmlImage Creates an image control, which is used to display an image.
HtmlInputCheckBox Creates a check box control.
HtmlInputRadioButton Creates a radio button control.
HTML table Creates a table control.
HtmlTableRow Creates a row within a table.
HtmlTableCell Creates a cell within a row.
Web Server Controls
Validation Controls
User Controls

15. What is CTS?
A
nswer: CTS stands for Common Type System. The CTS makes available a common set of data types so that compiled code of one language could easily interoperate with compiled code of another language by understanding each others’ data types. If two languages (c# or vb.net or j# or vc++) want to communicate with each other, they have to convert into some common type (i.e. in COMMON LANGUAGE RUNTIME). In C# we use int which is converted to Int32 of CLR to communicate with vb.net which uses Integer or vice versa.

16. What is object role modeling (ORM)?
A
nswer:
It is a logical model for designing and querying database models. There are various ORM tools in the market like CaseTalk, Microsoft Visio for Enterprise Architects, Infagon, etc.

17. What is the difference between user and custom controls?
Answer: User controls are easier to create whereas custom controls require extra effort.
User controls are used when the layout is static whereas custom controls are used in dynamic layouts.

A user control cannot be added to the toolbox whereas a custom control can be.
A separate copy of user control is required in every application that uses it whereas since custom controls are stored in the GAC, only a single copy can be used by all applications.

18. Where do custom controls reside?
Answer:
In the global assembly cache (GAC).

19. What is a third-party control?
Answer: Third-Party control is one that is not created by the owners of a project. They are usually used to save time and resources and reuse the functionality developed by others (third-party).  (Interview Questions and Answers)

20. What is Boxing/Unboxing?
Answer: Boxing is used to convert value types to object.

E.g. int x = 1;

object obj = x ;

Unboxing is used to convert the object back to the value type.

E.g. int y = (int)obj;

Boxing/unboxing is quite an expensive operation.

21. What is a COM Callable Wrapper (CCW)?
Answer: CCW is a wrapper created by the common language runtime(CLR) that enables COM components to access .NET objects.

22. What is a digital signature?
Answer: CA digital signature is an electronic signature used to verify/guarantee the identity of the individual who is sending the message.

23. What is garbage collection and explain its different generations?
Answer: The garbage collector is a part of Common Language Runtime, which does automatic memory management for your application. When you create an object in your application, CLR allocates the memory for that object on Managed Heap.
Garbage collector gives a number of benefits like –
Automatic Memory Management – You can build your application without thinking about how to free the memory as Garbage Collector gets called automatically by CLR.
Garbage Collector does proficient memory management for your objects.
Garbage Collector does automatic reclaim of the memory for those objects which are not in use and which are marked for deletion.
Garbage collector allocates the memory for objects in such a way that one object will not be able to use other object data accidentally.
garbage collection
The Managed Heap is a memory area where a series of managed objects are stored and managed. As shown in the above diagram, the managed heap gets divided into three different sections which are known as Generations.
Generation 0 – This is the first generation under managed heap which is used to store and manage short-lived objects. All small size objects usually get allocated on Generation 0. When garbage collector reclaims the memory, it always reclaims the memory from generation 0 by default. The objects which are survived in Generation 0 will be pushed towards the generation 1.
Generation 1 – This generation again contain the short-lived objects and the objects which are survived from Generation 0. The objects which are survived in Generation 1 will be pushed towards the generation 2.
Generation 2 – This generation contains the long-lived objects which are survived from multiple generations and are used until the process is running.
Garbage Collector first looks for the free memory in generation 0 which can be used to allocate the memory for the new object. The objects are always created in contagious memory. If the garbage collector finds sufficient memory for the new object, it does not search for the dead object and hence memory allocation process is always faster. But in case, sufficient memory is not available; then garbage collector reclaims the memory of the objects which are dead or not getting used for a long time.

When the Garbage collector gets executed, it first of all, finds all the live objects. After this garbage collector updates the addresses of objects which will be compacted. Then it reclaims the memory of all the dead objects. Once the memory is reclaimed, it moves the lived objects to the Next Generation. For example, the objects which live through in Generation 0 will be moved towards Generation 1. The objects which survived in generation 1 will be moved towards Generation 2. The objects which survived in Generation 2 will stay in Generation 2 only.

24. What is MIME?
Answer: The definition of MIME or Multipurpose Internet Mail Extensions as stated in MSDN is “MIME is a standard that can be used to include the content of various types in a single message. MIME extends the Simple Mail Transfer Protocol (SMTP) format of mail messages to include multiple contents, both textual and non-textual. Parts of the message may be images, audio, or text in different character sets. The MIME standard derives from RFCs such as 2821 and 2822”.

25. What is the difference between dispose() and finalize()?
Answer: 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.

26. What is cross-page posting in ASP.NET?
Answer: ASP.NET 1.1 provides for web forms posting back only to themselves. In many situations, the solution requires posting to a different web page. The traditional workaround alternatives were to use Response. Redirect and/or Server. Transfer to move to a different page and simulate cross-page post-back behavior.
ASP.NET 2.0 provides a feature known as Cross Page PostBack for a web form to post-back to a different web form (other than itself)
How to post to a different page
To set a web form to post back to a different web form, in the source web form, set the PostBackURL property of the control that implements IButtonControl (eg. Button, ImageButton, LinkButton) to the target web form. When the user clicks on this button control, the web form is cross-posted to the target web form. No other settings or code is required in the source web form.
Access source page info within the posted page: FindControl Method
The target web form resulting from the cross-page postback provides a non-null PreviousPage property. This property represents the source page and provides a reference to the source web form and its controls.
The controls on the source page can be accessed via the FindControl method on the object returned by the PreviousPage property of the target page.
protected void Page_Load(object sender, EventArgs e)
TextBox tx start date = (TextBox) PreviousPage.FindControl(“tx start date “);
At this point, the target page does not have any knowledge of the source page. The PreviousPage property is of the type of Page. For accessing controls using FindControl, the developer has to presume a certain structure in the source web form. This approach using FindControl has a few limitations. FindControl is dependent on the developer to provide the ids of the controls to access. The code will stop working if the control id is changed in the source web form. The FindControl method can retrieve controls only within the current container. If you need to access control within another control, you need to first get a reference to the parent control.
Access source page info within the posted page: @PreviousPageType Directive
There is another more direct option to get access to the source page controls if the source page is pre-determined. The @PreviousPageType directive can be used in the target page to strongly type the source page. The directive specifies the source page using either the VirtualPath attribute or the TypeName attribute. The PreviousPage property then returns a strongly typed reference to the source page. It allows access to the public properties of the source page.
SourcePage.aspx:
public string FirstName { get { return txtFirstName.Text; } } …
TargetPage.aspx
<%@ PreviousPageType VirtualPath=”sourcepage.aspx” %>
string strFirstName;
strFirstName = PreviousPage.FirstName //Strongly Typed PreviousPage allows direct access to the public properties of the source page

27. Explain “static” keyword in C# ?
Answer:
“Static” keyword can be used for declaring a static member. If the class is made static then all the members of the class are also made static. If the variable is made static then it will have a single instance and the value change is updated in this instance. (.net Training Online)

28. What is the difference between “dispose of” and “finalize” variables in C#?
Answer: Dispose of – This method uses interface – “IDisposable” interface and it will free up both managed and unmanaged codes like – database connection, files, etc.
Finalize – This method is called internally unlike Dispose method which is called explicitly. It is called by the garbage collector and can’t be called from the code.

29. What are Master Pages?
Answer: Master pages are a template that is used to create web pages with a consistent layout throughout your application. Master Pages contains content placeholders to hold page-specific content. When a page is requested, the contents of a Master page are merged with the content page, thereby giving a consistent layout.

30. How is a Master Page different from an ASP.NET page?
Answer: The MasterPage has a @Master top directive and contains ContentPlaceHolder server controls. It is quite similar to an ASP.NET page.

31. How do you attach an existing page to a Master page?
Answer: By using the MasterPageFile attribute in the @Page directive and removing some markup.
<%@ Page Language=”C#” MasterPageFile=”~/Template.master” AutoEventWireup=”true”
CodeFile=”About.aspx.cs” Inherits=”UI.About”

32. How do you set the title of an ASP.NET page that is attached to a Master Page?
Answer:
By using the Title property of the @Page directive in the content page. Eg:
<@Page MasterPageFile=”Sample.master” Title=”I hold content” %>

33. What is a nested master page? How do you create them?
Answer: A Nested master page is a master page associated with another master page. To create a nested master page, set the MasterPageFile attribute of the @Master directive to the name of the .master file of the base master page.

34. What are the differences between user and custom controls?
Answer: User controls are easier to create in comparison to custom controls, however, user controls can be less convenient to use in advanced scenarios.
User controls have limited support for consumers who use a visual design tool whereas custom controls have full visual design tool support for consumers.
A separate copy of the user control is required in each application that uses it whereas only a single copy of the custom control is required, in the global assembly cache, which makes maintenance easier.
A user control cannot be added to the Toolbox in Visual Studio whereas custom controls can be added to the Toolbox in Visual Studio.
User controls are good for static layout whereas custom controls are good for dynamic layout.

35. Where do you store your connection string information?
Answer: The connection string can be stored in configuration files (web.config).

36. What is the difference between ‘Web.config’ and ‘Machine.config’?
Answer: Web.config files are used to apply configuration settings to a particular web application whereasmachine.config file is used to apply configuration settings for all the websites on a web server.
Web.config files are located in the application’s root directory or inside a folder situated in a lower hierarchy. The machine.config is located in the Windows directory Microsoft.Net\Framework\Version\CONFIG.
There can be multiple web.config files in an application nested at different hierarchies. However, there can be only one machine.config file on a web server.

37. What is a stack? What is a heap? Give the differences between the two?
Answer: a Stack is a place in the memory where value types are stored. Heap is a place in the memory where the reference types are stored.

38. Explain the differences between value type and reference type?
Answer:
Following are the main differences between value type and reference type:

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

39. What is the difference between the session object and the application object?
Answer: 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 the application object, the id is maintained for the whole application. (C# .Net Training Videos)

40. What are mock-ups?
Answer: Mock-ups are a set of designs in the form of screens, diagrams, snapshots, etc., that helps verify the design and acquire feedback about the application’s requirements and use cases, at an early stage of the design process.

41. What is a web service?
Answer: Web Services are applications delivered as a service on the Web. Web services allow for programmatic access to business logic over the Web. Web services typically rely on XML-based protocols, messages, and interface descriptions for communication and access. Web services are designed to be used by other programs or applications rather than directly by end-user. Programs invoking a Web service are called clients. SOAP over HTTP is the most commonly used protocol for invoking Web services.

42. How can we improve the performance of an ASP.NET Web Page?
Answer: This is the most common question from ASP.NET forum to any interview. In this post, I’m going to point out some of the important points that may help to improve the performance.

Here I used the word “improve performance” in the sense to decrease the loading time of the page. There are various reasons behind. Some of them we look into from the “backend side” (Database side) and rest of them we need to take care in “front-end” ((UI) side.

For illustrative purpose, you have an ASP.NET Web site, one of the aspx page take much time to load. Throughout this article, we are going to see how to decrease the loading time.

43. Explain the Code Access Security (CAS) in the .NET framework?
Answer: .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.

All .NET Interview Questions

.Net Training Videos

Duration: 30+ Hours | Version: 6.0
999/-
  • Experienced Faculty
  • Real-time Scenarios
  • Free Bundle Access
  • Course Future Updates
  • Sample CV/Resume
  • Interview Q&A
  • Complimentary Materials

DOt net Tutorial Videos

up to 90% Off