Monday, May 5, 2014

Interview Questions


Interview Questions on .Net Framework

What is .Net framework?
In case of OS independent languages code executes under special software known as “Framework”.
“Framework is software which will mask the functionalities of an OS and makes the code to execute under its control” providing features like OS independency, security and automatic memory management.
What is CLR?
CLR is the core component of the .net framework responsible in execution of a .net application. It contains various things under it.
  1. Security Manager: which is responsible for managing the security of applications.
  2. Class loader:This is responsible for loading the required libraries for the execution of applications.
  3. JIT Compiler:It is responsible for converting IL code into machine code.
  4. Garbage Collector: This is responsible for automatic memory management, performing the cleanup of unused objects in a program i.e. whenever it identifies unused objects treats them as garbage and reclaims the memory allocated for that objects.
  5. Exception Handler: This is responsible for managing the runtime errors that occur within a program.
What is CLS?
It is a set of base rules all the high level .net languages has to adopt to interoperate with each other. Most importantly after compiling any .net language program it should generate the same type of output known as CIL code.
What is CTS?
According to this the data types that are present under every .net language should adopt similar structure. i.e. sizes of similar types should be uniform. The names of the types will not be similar in all these languages. But similar types present in different languages even if they don’t have the same name will have the same size.
When we use a type in any language after compilation that type gets converted into “IL” type as following
What is CIL?
Dotnet is a collection of languages which allows writing the source code in any dotnet language but once we compile it, it gets converted into CIL (Common Intermediate Language). CIL code can be executed on any machine with the help of CLR which takes the responsibility of converting CIL code into machine code specific to the OS.
What is Assembly?
Whenever a project is compiled it generates an output file that contains IL code of all items in the project known as assembly. These assemblies are what we carry on the client machines when the application has to be deployed. So they are referred as units of deployment. An assembly file can have an extension of either .exe or .dll
Can we consume classes of a project from other classes of same project?
Yes, we can consume them directly because all those classes were under same project and will be considered as a family.
Can we consume classes of a project from other classes of other project?
Yes, we can consume but not directly as they are under different projects, first we need to add reference of the assembly in which the class is present to the project who wants to consume it.
How to add reference of an assembly to a project?
To add a reference of an assembly to a project, Open solution explorer
  1. Right click on the project to whom reference has to be added
  2. Select Add reference
  3. Click browse tab on top of the window which has been open
  4. Select the assembly we want to consume from its physical location and click ok.

Now we can consume classes of that assembly referring with their namespace.
Define shared assembly?
An assembly that resides in a centralized location known as GAC (Global Assembly Cache) and provides resources to any no.of projects that wants to consume is known as shared assemblies. If an assembly is shared multiple copies will not be created even if being consumed by multiple projects, only a single copy under GAC serves all the projects. GAC is a folder that is present under the Windows folder.
C:\Windows\assembly
What assemblies can be copied into GAC?
We can copy only strong named assemblies into GAC.



No comments:

Post a Comment