25 .NET Basic Interview Questions and Answers

Dear Readers, Welcome to .Net Basic Interview questions with answers and explanation. These 25 solved .Net Basic questions will help you prepare for technical interviews and online selection tests conducted during campus placement for freshers and job interviews for professionals.

After reading these tricky .Net Basic questions, you can easily attempt the objective type and multiple choice type questions on this topic.

Difference between Namespace and Assembly

-Namespace can span multiple assemblies.
-Namespace logically groups class.
-Assembly is physical grouping of logical units.

Explain the concept of strong names.

-Strong Name is same as GUID in COM components
-Strong Names help GAC to differentiate between two versions
-It is required when we deploy assembly in GAC.
-Strong Names use public and private key concept

To sign an assembly with a strong name

- Create Key pair using the Strong Name utility, Sn.exe.
- Open the AssemblyInfo file of your project.
- Use the AssemblyKeyFileAttribute to specify the path to the key file for your project.
- Build your assembly. The strong name will be generated and signed to the assembly.

Explain GAC.

GAC stands for global assembly cache. It is an area of memory reserved to store the assemblies of all .NET applications that are running on a certain machine. It shares assemblies among multiple .NET applications. The assemblies must have a strong name and must be publicly shared to be installed in the GAC.

Define Assembly.

An Assembly is a collection, either an executable (.exe) or a dynamic link library (.dll), that forms a logical unit of functionality and built to efficiently work together. .NET Framework can be used to compile assemblies.

What is a Satellite assembly?

A satellite assembly contains resources specific to a given language.
With the help of these, the resources of different languages can be kept in different assemblies. However, at the runtime the chosen option generates the output in the desired language. The implementation code is kept different from the resource files that are used for conversion.

How do you install assembly to the Global Assembly Cache?

Following are the steps to install assembly to the GAC:

- Sign assembly with a strong name using strong name utility, sn.exe.
- Open the AssemblyInfo file for your project.
- Use the AssemblyKeyFileAttribute to specify the path to the key file for your project.
- Build your assembly. Install the assembly to GAC by using gacutil utility e.g. gacutil -i abc.dll

Explain the importance of Manifest in .NET

- .NET Manifest stores assembly metadata.
-Metadata is responsible in doing versioning of assembly, secure identify, resolve references to resources and classes

What is reflection?

-Reflection is used to browse through the metadata information.
-Using reflection you can dynamically invoke methods using system.Type.Invokemember

What are the namespaces provided by .net for data management?

-System.Data
-System.Data.OLEDB
-System.Data.SQLClient
-System.XML

Explain the steps to create a windows service.

Steps to create a windows service:

a. Create windows service project
b. Set the properties as per you want your service to work.
c. Write the processing for OnStart and OnStop.
d. Override the methods if required to fulfill user’s requirements.
e. Add installer
f. Build the project
g. Install the service and test it.

What are the differences between declarative and imperative security.

Declarative and imperative are the different syntax schemes used to implement security declarations in .NET Framework. In declarative security, attribute syntax is used. The security constraints are stored in the assembly at compile time. The disadvantage of declarative security is that there are tools which extract security requirements from the metadata in the assembly.

In imperative implementation, the attribute syntax is not used. It is implemented by writing the regular code to provide restrictions

What is Break mode?

When changes are made to the code in an application, the way to be able to view how those changes have changed the way of execution is Break Mode. In break mode, a snapshot of the running application is taken in which the status and values of all the variables is stored.

What are Trace switches?

Trace switches are used to enable, disable and filter the tracing output. They are objects can be configured through the .config file.

Explain the difference between dataset and datareader.

-Datareader provides forward-only and read-only access to data
-Dataset object can hold more than one table from the same data sources as well as the relationships between them.
-Dataset is a disconnected architecture
-Dataset cab persist contents while datareader cannot persist contents

What are different types of JIT?

-Pre-JIT
-Econo-JIT
-Normal-JIT

Where is version information stored of an assembly?

Version information is stored in assembly in manifest

Is versioning applicable to private assemblies?

Versioning concept is only applicable to global assembly cache.

What is Anonymous type in VB.NET? Explain its features.

An anonymous type is a class that contains one or more named values. Provides a quick and easy way to define simple classes for holding multiple values. Supports both mutable and immutable anonymous types.

Example.:
Dim myClass = New With {.Name= "john", .age = 59}

Compiler generates a type definition for the myClass, giving it a Name property as String and a Age property as int. This helps in late binding as well.

What is non_deterministic finalization?

Finalize method is executed whenever the runtime feels it is appropriate and cannot be controlled as such.

Example: When a low-resource condition occurs, this situation is referred to as non-deterministic finalization. Finalize method is thus executed by the runtime on a special thread allocated by the Garbage Collector.

How can we perform transactions in .NET?

-Open a database connection using open method of the connection object.
-Begin a transaction using the Begin Transaction method of the connection object.
-Execute the SQL commands using the command object.
-Commit or roll back the transaction using the commit or rollback method of the transaction object.
-Close the database connection.

What is the difference between Web.Config and Machine.Config?

Machine.config is one in a system and is the default configuration for all applications running on that machine. Web.config in every web application overrides the machine.config. Infact, a single web application can also have more than one web.config overriding each other in the increasing order of specificity. Each web.config must be of course at different levels/folders in a single application.

What is the advantage of packaging over xcopy in .NET?

The most trivial technique to publish a website is to simply copy your web application files to the production server and create a virtual directory there through xcopy command. With packaging it creates a self executable MSI which is very easy and convenient to deploy and install. This allows the end users to install a web application with ease. You could also include custom license needs, agreements, registry entries and other custom tasks such as installation folder etc for ease of the end users. The MSI can also be rolled out to many computers at once by the administrator which is a very big advantage.

What is STA in .NET?

Single-threaded apartments or the apartment model process offers a message-based paradigm for dealing with multiple objects running concurrently. It enables one to write more efficient code by allowing an awaiting thread to wait for another time-consuming operation to complete before it can be executed. Each thread in a process that is initialized as an apartment model process which retrieves and dispatches window messages, is a STA thread. Every thread lives within its own apartment. Within an apartment interface pointers can be passed without marshaling allowing all objects in a STA thread to communicate directly. It forms a logical grouping of related objects that execute on the same thread and therefore must have synchronous execution. That’s why the name apartment or single-threaded apartments.
Define .Net Assembly - .Net Assembly
.Net Assembly - An Assembly is a collection, either an executable (.exe) or a dynamic link library (.dll), that forms a logical unit of functionality and built to efficiently work together...
What does an assembly contain? - .Net Assembly
.Net Assembly - An assembly contains following information: Assembly manifest: Information about the assembly.....
Define a private assembly and a shared assembly - .Net Assembly
.Net Assembly - A private assembly is stored in the application’s directory and used by a single application......
Post your comment