Interview

.Net Interview Questions And Answer

Written by shohal

What is .NET?

.NET is a framework for software development. It is just like other software development framework. .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

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

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.

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

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

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

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 a Microsoft’s server side technology use 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.

What is the state management in ASP.NET?

State management is a technique that is used to manage a state of an object on different request. 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

What is the difference between trace and debug?

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

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

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

What is the difference between int and int32?

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

What is the difference between namespace and assembly?

An assembly is a physical grouping of logical units while namespace groups classes. A namespace can span multiple assemblies.

Explain the differences between value type and reference type.

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

  • Value type contain variable 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

What is the difference between session object and application object?

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

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

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 block in procedures but that is not possible in function.

How to retrieve user name in case of Window Authentication?

System.Environment.UserName

What is the difference between Hash table and Array list?

Hash table stores data in the form of value pair and name while Array list stores only values.

You need to pass 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 type of data type while in Hash table you can store different type of data types. ex. int, string etc.

What is the meaning of Immutable?

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.

What are the advantages of using session?

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.

What are the disadvantages of using session?

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.

Can you set the session out time manually?

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

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.

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

No.

What is HTTPhandler?

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

What is .NET Framework and what are the main components of it?

.NET Framework facilitates the developer to develop, run and deploy the applications like console application, window Forms applications, web applications, web services, window services etc. It also provides environment to create sharable components to be used in distributed computing architecture.

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.

What is manifest in .NET Framework?

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

What are the memory-mapped files?

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

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

System.GC.Collect() method.

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

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.

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

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

What is Garbage collection?

Garbage collection is used to prevent memory leaks during execution of programs. There is a low-priority process name as garbage collector manages the allocation and deallocation a memory for applications. It also checks for the unreferenced variables and objects. If there is ny object which is no further used by application the Garbage collector frees up the memory from that object.

How can you identify that the page is post back?

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

What is variable and constant in .NET programming language?

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;  

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

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

What are the different types of indexes in .Net?

There are two types of indexes in .Net:

Clustered index and non-clustered index

How many types of memories are there in .Net?

There are two types of memories in .Net

  • Stack memory
  • Heap Memory

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

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

What are cookies?

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

What are the disadvantages of cookies?

The main disadvantages of cookies are:

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

What is an IL?

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.

IL is compiled, not interpreted.

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

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

What are tuples in .Net?

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.

How many elements a tuple can hold?

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

Which architecture does a Dataset follow?

A Dataset follows the disconnected data architecture.

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

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.

What are the basic requirements for connection pooling?

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.

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

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

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

The following parameters control the connection pooling behavior:

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

What do you mean by AutoPostBack?

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.

Which properties are used to bind a DataGridView control?

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

About the author

shohal

Leave a Comment