Blog

Blog

Top 50 .NET Interview Questions To Look Out For In 2023

.NET Interview Questions

.NET Interview Questions

1. What is .NET?

.Net is a software framework of Microsoft for developing applications on Windows. It is similar to other software development frameworks like Java Platform, Enterprise Edition (J2EE), and comprises ASP .Net, languages such as C#, VB .Net, COBOL, Perl, etc.

2. What is ASP.NET?

ASP.NET is another software framework to build web applications and is a part of the .NET Framework. ASP.NET helps to build the front end and runs on IIS, a Web Server.

3. What is CLR?

CLR refers to Common Language Run-time. It is an essential component of the .NET framework and can be used as a building block of various applications. An essential feature of CLR is that it ensures a secure execution environment for applications.

4. What is CLS?

CLS refers to Common Language Specification. It allows users to use inter-language compatible components and helps to reuse the code in other .NET compatible languages.

5. Differentiate between boxing and unboxing.

The following are the difference between boxing and unboxing:

BoxingUnboxing
Implicit conversionExplicit conversion
Object type refers to the value typeRetrieve value from the boxed object
int n = 12;object ob = n;int m = (int) ob;

6. What is BCL?

BCL refers to Base Class Library. It is the foundation of .NET framework applications, components, and controls. It comprises of basic, fundamental types like System.String and System.DateTime and offers functionalities like threading, input/output, security, diagnostics, etc.

7. What are cookies?

Cookies are small bits of text information. Cookies are created by the server on the client for identifying users. It may contain the username and ID, interests, password remember option, or any other information. Cookies are domain-specific.

8. Name some of the disadvantages of cookies.

The main disadvantages of cookies include:

  • Possible security risk, as they are stored in a clear text
  • Not secure, as encryption & decryption is easy
  • Cookies can be disabled on any user’s computer
  • Can be edited or deleted
  • Cookies can store limited data.

9. How many languages are supported by .NET?

.NET supports almost 60 languages, including:

  • C#.NET
  • VB.NET
  • C++.NET
  • J#.NET
  • F#.NET
  • JSCRIPT.NET
  • WINDOWS POWERSHELL

10. Differentiate between ASP.NET and ASP.

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

ASP.NETActive Server Pages (ASP)
Creates dynamic web applicationsCreates web pages
CompiledInterpreted
Uses ADO.NETUses ADO
Completely object-orientedPartially object-oriented

11. Explain state management in ASP.NET.

State management is the process of managing the state of one or more user interface controls such as text fields, OK buttons, radio buttons, etc. in a graphical user interface. Two types of state management systems are there in ASP.NET –

  • Client-side state management
  • Server-side state management

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

The difference between function and stored procedure:

FunctionStored procedure
Returns only one valueReturns one or more than one value
Used in select statementsCannot be used in select statements
Has only input parameterHas both input and output parameters
It can’t handle exceptionsIt can handle exceptions using a try-catch block

13. How would you retrieve user names for Windows Authentication?

Username for Windows Authentication can be retrieved by using:

System.Environment.UserName

14. Name the advantages of using Session State.

The advantages of Session State include –

  • Easy to implement
  • Stores user states and data across the application
  • Ensures data durability
  • Works in multi-process configuration, thereby ensuring platform scalability
  • Stores session object on the server. Keeping it secure and transparent for the user

15. What is HTTPhandler?

HttpHandler is a low-level request and response API in ASP.Net. It is used by the ASP.NET web application server to handle specific extension-based requests.

16. Name the methodology used to enforce garbage collection in .NET.

The methodology used to enforce garbage collection in .NET is System.GC.Collect().

17. How many types of indexes are there in .NET?

There are two types of indexes in .Net:

  1. Clustered index
  2. Non-clustered index

18. How many types of memories do exist in .Net?

There are two types of memories in .Net

  • Stack memory
  • Heap Memory

19. What is IL?

IL refers to Intermediate Language and is an object-oriented programming language to be used by the compilers. It gets changed over to byte code when a virtual machine is being executed. IL is also known as Common Intermediate Language (CIL) or Microsoft Intermediate Language (MSIL).

20. What is LINQ?

LINQ notices to Language Integrated Query. It was introduced with visual studio 2008 and is a uniform query syntax in C# and VB.NET for data retrieval from different sources and data manipulation irrespective of the data source.

21. Name different types of constructors in C#.

Different types of constructors in C# are Copy Constructor, Default Constructor, Parameterized constructor, Private Constructor, and Static Constructor.

22. Write the differences between Custom Control and User Control.

Custom control and user control differ as follows:

Custom ControlUser Control
Inherits from the System.Windows.Controls.Control classInherits from the system.Windows.Controls.UserControls class
Designed for single-application scenariosDesigned for multi-application scenarios
Introduces redundancy and maintenance problems if used on more than one applicationCan be distributed without facing any problems associated with redundancy and maintenance
Loosely coupled control with respect to code and UITightly coupled control with respect to code and UI

23. What is Garbage Collector in .NET?

The garbage collector is responsible to free up the unused code objects in the memory. Every time a new object is created, the common language runtime allocates memory for the object.

24. What are the different events in the Page Life Cycle?

Different events in the Page Life Cycle include:

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

25. Name all the templates of the Repeater control.

Templates of the Repeater control are:

  • ItemTemplate
  • AlternatingItemTemplate
  • SeparatorTemplate
  • HeaderTemplate
  • FooterTemplate

26. What code we can use to send e-mail from an ASP.NET application?

We can write a given code to send an e-mail:

MailMessage mailMess = new MailMessage ();

mailMess.From = “[email protected]”;

mailMess.To = “[email protected]”;

mailMess.Subject = “Test email”;

mailMess.Body = “Hi check this test mail.”;

SmtpMail.SmtpServer = “localhost”;

SmtpMail.Send (mailMess);

MailMessage and SmtpMail are classes defined System.Web.Mail namespace.

27. Explain Polymorphism?

Polymorphism is used as an interface with various functions. In this interface, a similar method or property can work on different actions depending on the run-time type of the instance.

28. Mention different types of Polymorphism?

Following are two types of Polymorphism:

  • Static or compile-time polymorphism
  • Dynamic or runtime polymorphism

29. Mention the design principles used in .NET?

In .Net, SOLID design principle is used, take a look at the following design principles:

  • Open-Closed Principle (OCP)
  • Single responsibility principle (SRP)
  • Interface segregation principle (ISP)
  • Liskov substitution principle (LSP)
  • Dependency inversion principle (DIP)

30. Explain Marshaling in .Net.

Marshaling is defined as the process of transforming types in the managed and unmanaged code. It is the most important service given by CLR.

31. What are Boxing and Unboxing?

Boxing and Unboxing are defined as a concept of C#, where a unified view of the type system is enabled to treat the value of any type as an object.

32. Mention the divisions of the Memory Heap?

Following is the division of the memory heap into three generations.

Generation 0 – Used to store short-lived objects. Quick Garbage Collection occurs in this Generation.

Generation 1 – Used for medium-lived objects.

Generation 2 – Used for long-lived objects.

33. Brief about the managed code.

It is a code whose execution is managed through runtime(CLR). For the execution of managed code, .NET framework is necessory. In the case of these codes, memory management is performed via garbage collection.

34. How do we execute managed code?

To execute managed code, we can follow these steps:

  • Select a language compiler depending on the language of the code.
  • Convert the code into Intermediate language using its compiler.
  • The IL is then targeted to CLR which transforms the code into native code using JIT.
  • Execute Native code.

35. Name the different types of assemblies?

The two different types of assemblies are:

  • Private Assembly: Accessible only to the application.
  • Shared Assembly: Can be shared by multiple applications.

36. Mention the different parts of an Assembly?

Following are the different parts of an Assembly:

  • Manifest – Stores the information about the version of an assembly.
  • Type Metadata – Stores the binary information of the program.
  • MSIL – Microsoft Intermediate Language code.
  • Resources – List of related files.

37. List the advantages of Web Services?

Following are the advantages of Web Services:

  • It is stateless and firewall-friendly.
  • Easy to create and supported by multiple platforms.
  • It can extend its interface and add new methods without affecting the client’s operations.

38. What is ADO (ActiveX Data Objects)?

ADO is an application program used for writing Windows applications. It is also used to get access to a relational or non-relational database from database providers such as Microsoft and others.

39. List the fundamental objects in ADO.NET?

Following are the fundamental objects in ADO.NET:

  • DataReader- connected architecture
  • DataSet- disconnected architecture

40. What is a PE file?

PE stands for Portable Executable. It is a derivative of the Microsoft Common Object File Format (COFF).  Windows executable, .EXE or DLL files follow the PE file format. It consists of four parts:

  1. PE/COFF headers- Contains information regarding .EXE or DLL file.
  2. CLR header- Contains information about CLR & memory management.
  3. CLR data- Contains metadata of DDLs and MSIL code generated by compilers.
  4. Native image section- Contains sections like .data, .rdata, .rsrc, .text etc.

41. What is the difference between DLL and EXE?

.EXE files are single outbound files that cannot be shared with other applications. DLL files are multiple inbound files that are shareable.

42. .NET is an OOP or an AOP framework?

.NET is an OOP framework as Encapsulation and Inheritance are key features of the Object-Oriented Programming framework.

43. What is Just In Time (JIT)?

Just In Time (JIT) is a compiler in the CLR that is responsible for executing .NET programs of different languages. This is done by converting them into machine code. It speeds up the execution of code and supports multiple platforms. There are three types of Just In Time compilers including:

  1. Pre-JIT compiler: It compiles all source code into the machine code in one compilation cycle, i.e. at the time of application deployment.
  2. Normal JIT compiler: Source code methods needed at the run-time, are compiled into the machine code and is stored in the cache that is to be called later.
  3. Econo JIT compiler: Methods required only at the run-time are compiled through this compiler and are not stored for use in the future.

44. What is Framework Class Library(FCL)?

Framework Class Library is used for the development of various applications since it offers access to system functionality. It is a collection of reusable types including interfaces, classes and data types which are included in the .NET Framework. 

45. What is caching in .NET?

Caching is a functionality in the .NET Framework that allows data storage in the memory for rapid access. It is used for performance improvement by making the data available, even when the data source is temporarily unavailable and it enhances scalability. There are three types of caching in the .NET including In-memory cache, persistent in-process cache, and distributed cache.

46. What are the different types of caching?

The different types of caching in .Net are:

  • Page caching
  • Data caching
  • Fragment caching

47. Explain the characteristics of .Net core.

The following are the characterstics of .Net core:

  • Speed: It is fast in comparison with the .NET framework and previous versions.
  • Multiple support: This framework is supported by various operating systems such as Linux, macOS and Windows.
  • Application development: It is used for developing different types of applications such as IoT, microservices, machine learning, etc.
  • Compatibility: It is compatible with Mono, Xamarin and .NET framework via .NET standard. It also supports work with various libraries and web frameworks such as JavaScript and React.

48. What are security controls available on ASP.NET?

There are five security controls available on ASP.NET:

  1. <asp:Login> Provides login capability that allows users to enter credentials using ID and password fields.
  2. <asp:LoginView>Provides a range of views based on the selected template.
  3. <asp:LoginName>Displays the user name who has logged in.
  4. <asp:PasswordRecovery>: This sends email to users while resetting the password
  5. <asp:LoginStatus>Used for checking whether the user has been authenticated or not.

49. Explain the difference between value type and reference type?

The following points explain the difference between value and reference type:

  1. Value type holds data directly into the memory location. On the other hand, the reference type consists of a pointer that has the address of memory location that holds actual data.
  2. When you assign a vale type variable to another variable, it will copy the value directly. When you assign the reference variable to another variable, it does not copy the variable but creates the second copy of the reference.
  3. Value type stores its content on stack memory whereas reference types stores content on the heap memory.

50. What is inheritance? Explain its importance.

Inheritance is a crucial aspect of object-oriented programming that allows developers to create new classes that are built upon existing classes. This is achieved by reusing, extending, and modifying the behaviours defined in classes. The class whose members are inherited is the base class, while the class that inherits those members is called the derived class.

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare

Subscribe to Newsletter

Stay ahead of the rapidly evolving world of technology with our news letters. Subscribe now!