.Net interview questions

Get Technical Answers for .Net Interview Questions by .Net Developers, Advanced Technical Questions for Freshers and Experience Persons. Get Free Practical Tests.

1. What are the different components of .NET?

Ans: The components of .NET are

  • Common Language run-time
  • Application Domain
  • Common Type System
  • .NET Class Library
  • .NET Framework
  • Profiling

2. What are the design principles used in .NET?

Ans: The .NET uses the following design principles.

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

3. What is CLR?

Ans: 

  • CLR is a major component of the .NET framework that stands for common language run-time. The CLR can be used as a building block of various applications and provides a secure environment for executing the applications.
  • Whenever a C# application 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.

4. What are the different parts of an Assembly?

Ans: The different parts of an assembly include.

  1. Manifest: It contains information about the version of the assembly.
  2. Type Metadata: It contains the binary information of the program.
  3. MSIL: Microsoft Intermediate Language Code.
  4. Resources: It contains a list of related files.

5. What is the difference between “Response.Redirect” and “Server.Transfer”?

Ans: 

Response.Redirect: 

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

Server.Transfer:

It transfers from one page to the other without making any round-trip back to the client’s browser. The history will not be updated in this scenario of “Server.Transfer”.

6. What is LINQ?

Ans: 

  • LINQ stands for Language integrated query which was introduced with visual studio 2008. 
  • It is a set of features that extend query capabilities to the .NET framework language syntax that allows data manipulation irrespective of the data source. 
  • It bridges the gap between the world of objects and the world of data.

7. What is the difference between custom and user control?

Ans:

Custom control:

  • It derives from control.
  • It is based on dynamic layout.
  • Defines a single control.
  • It has the support of a full toolbox.
  • It is loosely coupled.

User control:

  • It derives from the user control.
  • It is based on a static layout.
  • Defines a set of controls.
  • It cannot be added to the toolbox.
  • It is tightly coupled.

8. Can we assign null value into value type variable?

Ans: No but we can assign null values into reference type variable

9. When we will declare particular variable as nullable type?

Ans: Whenever an input is an optional that means not compulsory then we candeclare particular variable as NULLABLE TYPES

10. What is implicit type casting? When we will go for explicit type casing?

Ans: 

IMPLICIT TYPE CASTING: -

Converting from a Smaller size data type to a bigger size data type is called IMPLICIT TYPE CASTING

When EXPLICIT TYPE CASTING:

The type casting which is not possible by using implicit type casting then we have to go for EXPLICIT TYPE CASTING

11. List all the templates of the Repeater control.

Ans: 

  • ItemTemplate.
  • AlternatingItemTemplate.
  • SeparatorTemplate.
  • HeaderTemplate.
  • FooterTemplate.

12. Differentiate between constants and read-only variables.

Ans:

Constants:

  • Constants are evaluated at compile time.
  • It supports only the value type variables.
  • Constants are used when the value is not changing at compile time.
  • It cannot be initialized at the time of declaration or in a constructor.

Read-only variable:

  • Read-only variables are evaluated at run time.
  • It can hold the reference type variables.
  • Read-only variables are used when the actual value is unknown before the run-time.
  • It can be initialized at the time of declaration or in a constructor.

13. What are MDI and SDI?

Ans:

MDI( Multiple Document Interface): 

This interface lets you open multiple windows, it contains one parent window with many child windows. The components are shared from the parent window like menubar, toolbar, etc.

SDI( Single Document Interface): 

This interface opens each document in a separate window. Each window has its own components like menubar, toolbar, etc. Hence it is not constrained to the parent window.

.Net Training Certification

  • Master Your Craft
  • Lifetime LMS & Faculty Access
  • 24/7 online expert support
  • Real-world & Project Based Learning

 

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

Ans: There are only two different validators in ASP.NET

  1. Client-side validation: It is the validation which is performed on the client-side browser. Generally, JavaScript is preferred for client-side validation.
  2. Server-side validation: It is the validation which is performed on the server. It is treated 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.

15. Write the simple code to send an email from an ASP.NET application.

Ans: 

mail message = new mail();

message.From = "abc@gmail.com";

message.To = "xyz@gmail.com";

message.Subject = "Test";

message.Body = "hello";

SmtpMail.SmtpServer = "localhost";

SmtpMail.Send(message);

16. What is cross-page posting?

Ans: 

  • Upon clicking a submit button on a page, the data is stored on the same page. It is called cross-page posting when this data is stored on a different page.
  • Cross-page posting can be achieved by “POSTBACKURL” property which causes the postback.
  • FindControl() method is used for getting the values that are posted on this page to which the page has been posted.

17. How can you apply themes to an ASP.NET application?

Ans: To themes specification, the web.config file will be used in ASP.NET application.

<cofiguration>

<system.web>

<pages theme="windows"/>

</system.web>

</configuration>

18. What are ASP.NET security controls?

Ans:

  • It enables the login capability for users to enter their credentials.
  • It allows you to display the name of the logged-in user.
  • It displays the status of the user if they are authenticated or not.
  • It provides various login views depending on the template that has been selected.
  • It emails the users who have lost their passwords.

19. What is the difference between ExecuteScalar and ExecuteNonQuery?

Ans:

ExecuteScalar:

  • It returns an output value.
  • It is used for fetching a single value.
  • It doesn’t return any number of affected rows.

ExecuteNonQuery:

  • It doesn’t return any output value.
  • It is used to execute insert and update statements.
  • It returns the number of affected rows.

20. What is HTTP Handler?

Ans:

  • HTTP handler is a specialized component that handles every request of an ASP.NET application. It is the most crucial component that handles application requests of ASP.NET.
  • It uses various handlers for serving different files. To a web page, the handler creates the page and controls objects which run your code and then delivers the final HTML.

Following are the default HTTP handlers for ASP.NET:

  1. Page Handler(.aspx): It handles web pages.
  2. User Control Handler(.ascx): It handles web user control pages.
  3. Web Service Handler(.asmx): It handles web service pages.
  4. Trace Handler(trace.axd): It handles trace functionality.

21. What is a delegate in .NET?

Ans: 

  • A delegate in .NET is a similar function pointer which is used in other programming languages such as C or C++. 
  • It 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. 
  • The delegate method is used for creating a custom event in a class.

22. What is the difference between DLL and EXE?

Ans: 

.exe:

  1. These are outbound files.
  2. Only one “.exe” file exists per application.
  3. These files cannot be shared with other applications.

.dll:

  1. These are inbound files.
  2. There can be many “.dll” files that may exist in one application.
  3. These files can be shared with other applications.

23. What is Object Pooling?

Ans: 

  • Object pooling is a concept of storing a pool which means a group of objects in memory that can be reused later as needed. 
  • Whenever a new object is created as per requirement, an object from the pool can be allocated for this request; thereby, minimizing the object creation. 
  • A pool is also referred to as a group of connections and threads. Hence it is helpful in minimizing the usage of system resources and improves system scalability and performance.

Subscribe to our youtube channel to get new updates..!

 

24. What is the difference between dataset.clone and dataset.copy?

Ans: 

dataset.clone: 

It copies the structure of the DataSet which includes all DataTable schemas, relations and constraints. It doesn’t copy any data.

dataset.copy: 

It copies both the structure and data for the DataSet. It is a deep copy which duplicates the structure and data.

25. What is the difference between managed and unmanaged code?

Ans: 

Managed code:

  • This code is managed by CLR.
  • The .NET framework is a must for executing the managed code.
  • CLR manages memory management through garbage collection.

Unmanaged code:

  • It is the code which is not managed by CLR.
  • It is independent of the .NET framework.
  • It uses its own runtime environment for compilation and execution.

26. What is ViewState?

Ans: 

  • It is a feature used by the ASP.NET Web page for storing the value of a page and its controls just before posting the page. 
  • Once the page is posted, the primary task of page processing is to restore the ViewState to retrieve the values of the controls.

27. What is the use of ErrorProvider Control in .NET?

Ans: 

  • The ErrorProvider control is used for indicating the invalid data on a data entry form. 
  • Using ErrorProvider control, the error messages can be attached which are displayed next to the control when the data is invalid.

28. What is the appSettings section in the “web.config” file?

Ans: In order to set the user-defined values for the whole application, the “appSettings” block that is available in the “web.config” file can be used. 

Example: 

The below code 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>

29. What is the difference between the While and For loop? Provide a .NET syntax for both loops.

Ans: 

For Loop:

  • The For loop provides a concise way to write the structure of loop,
  • Initialization, condition checking, iteration statements are written at the top of the “for” loop.

Syntax:

for(intialization; condition; Increment or decrement){

// statements to be executed.

}

While Loop:

  • The While loop is a control flow statement that allows repetitive execution of the code. 
  • Only initialization and condition checking are done at the top of the while loop.

Syntax:

while(condition) {

//statements to execute.

}

30. Differentiate between Task and Thread in .NET.

Ans: 

Thread:

  • The thread represents an actual OS-level thread, which contains its own stack and kernel resources, and allows the highest degree of control. 
  • It allows you to choose Abort() or Suspend() or Resume() methods and set thread-level properties, such as stack size, apartment state, or culture. 

Task:

  • A Task class from the Task Parallel Library is executed by a TaskScheduler.
  • The task returns a result and allows you to find out when it finishes.

31. What is the difference between function and stored procedure?

Ans: 

Function:

  • It must return a single value.
  • It can have only an input parameter.
  • Exception handling can’t be performed using a try-catch block.
  • Calling a stored procedure from a function is not possible.

Stored Procedure:

  • It always performs a specific task.
  • It can have both input and output parameters.
  • Exception handling can be performed using a try-catch block.
  • Calling a function from a stored procedure is possible.

32. What is caching?

Ans: Caching is the process of storing the data temporarily in the memory such that the data can be accessed from the memory instead of searching for it in the original location. It increases the speed and efficiency of an application.

Following are the types of caching:

  • Page caching.
  • Data caching.
  • Fragment caching.

33. What is a PE file?

Ans: 

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

34. What are the advantages of Informatica?

Ans: 

  • NET Framework is an important integral component in NET software
  • Net Framework is a runtime environment, which we can use to run net applications

.Net Training Certification

Weekday / Weekend Batches

 

35. What is Visual StudioNet?

Ans: AVisual Studio NET is a Microsoft-integrated development environment (IDE)that can be used for developing console applications, Windows Applications, Web Applications, Windows Service, Web service And so on

36. What is CLR?

ans: CLR Stands for Common Language Runtime,it is net execution
CLR is a common execution engine for all NET Languages that means every NET language application has to execute with the help of CLR

37. What is JIT Compiler?

Ans: AJIT (JUST-IN-TIME Compiler will convert MSIL (Microsoft Intermediate Language code to Native code because operating system can understand only Native code or machine code. 

38. What is CLS?

Ans: 

  • CLS (Common Language Specifications is a set of common language standard defined by the Microsoft for all NET Languages
  • Every NET Language has to follow CLS Standards
  • Whenever a Programming Language wants to recognize as NET Language then it has to follow CLS

39. When we will go for instance variable?

Ans: AWhenever we required a filed for multiple objects with the different values,then particular variable we will declare as INSTANCE VARAIBLE

40. Why class and object?

Ans: 

CLASS:

To achieve ENCAPSULATION, as well as for modularity

OBJECT:

To allocate memory for instance variables & to store the address ofinstance method

41. What is Error, Bug and Defect?

Ans: 

Error

--> Which comes at the time of development

Bug

 --> Which comes at the time of testing (Pre-Release)

Defect

 --> Which comes in Production (Post-Release

42. What is Boxing and Unboxing?

Ans: 

BOXING: -

It is the process of converting from VALUE type toREFERENCE typeEx: converting from int to object

UNBOXING: -

It is the process of converting from REFERENCE type toVALUE typeEX: converting from object to int

43. Why C#Net?

Ans: ATo develop any type of application by using NET we require one NETLANGUAGE to write the business logic of that applicationATo develop any type of application by using NET we require one NETLANGUAGE to write the business logic of that application

44. What is the MaxValue and MinValue?

Ans: A Max Value and Min Value are predefined constants, which are members of every primitive data type structure except bool Using this Constant we can get the MINIMUM value and MAXIMUM value of a data type

45. What is Managed Code and Unmanaged Code?Net application may contain 2 types of codesAManaged Code BUnmanaged Code

Ans: 

Managed code:

The code which is taking the help of CLR for execution is called as managed code example for Managed Code:-All net languages code is managed codeVBNet code,
C#Net code…etc

Unmanaged code: -

The code which is not taking the help of CLR for execution is called asUnmanaged codeExample for Unmanaged Code:-In net application non net code is unmanaged codeVB Code,

VC++ Code…
Note: - net application can contain non net code

Submit an interview question

Categories

Request for more information

John
John
Cloud Technologies & Cyber Security
John is a Post Graduate in Computer Science from Andhra University .She is currently working as an IT developer at hkr trainings.com. And he has great experience includes both IT development and operational roles. Connect with him on LinkedIn and Twitter. Thank you

WhatsApp
To Top