The blog has moved to the new site F10Debug.com
Showing posts with label .Net Framework interview questions and answers. Show all posts
Showing posts with label .Net Framework interview questions and answers. Show all posts

Saturday, June 11, 2016

.Net Framework interview questions and answers part2

6. What is Common Language Specification (CLS)?

This is a subset of the CTS, which all .NET languages are expected to support. It was always a dream of Microsoft to unite all different languages in to one umbrella and CLS is one-step towards that. Microsoft has defined CLS, which are nothing but guidelines that language should follow so that it can communicate with other .NET languages in a seamless manner.

7. What is an IL or MSIL or CIL?

Intermediate Language (IL) is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). 
All .NET source code is compiled to IL. 
IL is then converted to machine code or at run-time by a Just-In-Time (JIT) compiler.

8. What is Garbage collection / Memory Management in .Net?


Garbage collection is automatic process performs by Garbage collector (which lives in CLR) to free up memory of objects which are no longer in used.

Every time you create a new object, the common language runtime allocates memory to store that object. But at some point that object may be no longer needed by your application. So that garbage collector deallocates memory of this type of objects, so that application can store new objects into memory. If memory is not deallocated then sooner your application will run out of memory.

Interview Questions Related to garbage collections

a. How does Garbage collection works?


Every time a garbage collection is performed, the garbage collector basically looks at the memory and frees up memory which is no longer needed, that is, memory which is occupied by ‘dead objects’.

b.  How does it know when an object is ‘dead’?

An object is dead if it is unreachable by your code. The obvious example is a local variable inside a method. There is no way for your code to access that variable once the method has returned, so it becomes ‘dead’.

C.  How often does the garbage collector perform a garbage collection?

There are three ways a garbage collection can be triggered. 
Firstly, if your system has low physical memory, this can trigger a garbage collection.
Secondly, a threshold is defined which indicates an acceptable level of memory on the heap which can be used by allocated objects. If this threshold is surpassed, then a garbage collection is triggered.
Finally, a garbage collection can explicitly be triggered by calling the GC.Collect method. Only under very rare circumstances is this ever required.

Friday, April 22, 2016

What is assembly in .Net Framework ?

An assembly is a collection of types (namespaces, classes, struct, interfaces etc.) and resources that are built to work together and form a logical unit of functionality. Assembly can be .exe or .dll depends on type of application.

If application is console then .exe is generated & if application is Class Library then .dll is generated.

Suppose we have created one console application ‘Test’ as below,




In this application we have types (interface as ‘Interface1’ and class as ’program.cs’) so when we build this application one .exe will be generated. In this example test.exe will be generated.


Generated .exe can be viewed at -> Project folder -> bin -> debug -> ApplicationName.exe



Here assembly generated at path -> Csharp (solution name) -> Test (appliation name) -> bin -> debug
Assembly generated -> Test.exe
So now Test.exe (assembly) will have collections of types (Interface1 and Program) and resoruces which forms as logical unit of funcationality.
Assembly name consists of 4 parts,
a) Simple textual name

b) Version Number 

c) Culture information

d)  Public key token 

Tuesday, April 19, 2016

What is an IL or MSIL or CIL?


  • Intermediate Language (IL) is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language).
  • All NET source code is compiled to IL. 
  • IL is then converted to machine code or at run-time by a Just-In-Time (JIT) compiler.

What is Common Language Specification (CLS)?

This is a subset of the CTS, which all .NET languages are expected to support. It was always a dream of Microsoft to unite all different languages in to one umbrella and CLS is one-step towards that. Microsoft has defined CLS, which are nothing but guidelines that language should follow so that it can communicate with other .NET languages in a seamless manner. 

What is .Net Framework Class Library (FCL)?

The .NET Framework class library is collections of namespaces, classes, interfaces & value types that provide access to system functionality. It is the foundation on which .NET Framework applications, components, and controls are built.

For Ex.:  In Every .Net Program we use system namespace
using System;

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Dotnetpeoples...");
        }
    }
}


and this system namespace present in System assembly. 




And this system assembly located at path -> C:\Windows\Assembly (Which is also called as GAC)

Global Assembly Cache. So All the assembly which are reside in GAC are part of .Net Framework class library 

and get installed automatically along with .Net framework.


What is Common Type System (CTS)?

Microsoft .Net framework supports multiple programming languages, so in order to communicate between different programming languages Microsoft introduces CTS. 

CTS are set of standard data types which are common between all the .net programming languages, so that one language can communicate easily with another language.

CTS convert the data types of all .Net programming languages to common data type so that different programming languages can communicate easily.

For Ex. OR How CTS converts the data type to a common data type


In VB.Net we declare integer as Integer and in C#.net we declare integer as int. So in order to communicate between this languages CTS coverts them into common data type as “System.Int32”.


CTS                    

What is Common Language Runtime (CLR) ?

CLR
The .NET Framework provides a run-time environment called the common language runtime.  A runtime is an environment in which programs are executed. 

CLR is the heart of the .Net framework.

Advantages of CLR / CLR does following important things,

1. Garbage collection / Memory Management

2. Code Access Security (CAS)

3. Code Verification

4. Compilation of IL to Native translation. 

5. Application portability  - Supports multiple operating system.

What are the main components of .NET Framework?

The .NET Framework contains three major components,

  • Common Language Runtime (CLR)
  • .NET Framework Class Library (FCL)
  • Common Type System (CTS)

.NET Framework Interview Questions & Answers

Coming soon

Saturday, April 16, 2016

What is Microsoft .Net Framework ?

A programming platform created by Microsoft that allows developer to develop, run, and deploy the following applications and services that use .NET technologies, such as such as desktop & web applications and Web services.

The .NET Framework contains three major parts:
  • Common Language Runtime (CLR)
  • .NET Framework Class Library
  • Common Type System (CTS)
.Net framework supports mulitple programming launguages such as C#.Net, Visual Basic & Visual C++ etc, so that we can use code of one programming launguage into other launguages.