Books of .Net/Interview Questions Interview Questions and Answers Programs C# Concept OOPS Concept JOBS

Sunday, August 27, 2017

.NET FRAMEWORK INTERVIEW QUESTIONS AND ANSWERS



Question 1) What is Common Language Runtime (CLR) ?
Answer -
 As part of the Microsoft .NET Framework, the Common Language Runtime (CLR) is the programming (Virtual Machine component) that manages the execution of programs written in any language that uses the .NET Framework, 
for example C#, VB.Net, F# and so on. Programmers write code in any language, including VB.Net, C# and F# when they compile their programs into an intermediate form of code called CLI in a portable execution file (PE) that can be managed and used by the CLR and then the CLR converts it into machine code to be will executed by the processor. The information about the environment, programming language, its version and what class libraries will be used for this code are stored in the form of metadata with the compiler that tells the CLR how to handle this code. The CLR allows an instance of a class written in one language to call a method of the class written in another language. 

Functions of the CLR 
  • Convert code into CLI.
  •  Exception handling 
  • Type safety 
  • Memory management (using the Garbage Collector) 
  • Security Improved 
  • performance Language independency 
  • Platform independency 
  • Architecture independency 
Components of the CLR 
  • Class Loader -  Used to load all classes at run time. 
  • MSIL to Native code  - The Just In Time (JTI) compiler will convert MSIL code into native code. 
  • Code Manager -  It manages the code at run time.
  •  Garbage Collector -  It manages the memory. Collect all unused objects and deallocate them to reduce memory. 
  • Thread Suppor  - It supports multithreading of our application. 
  • Exception Handler - It handles exceptions at run time.
The runtime provides the following benefits: 


  • + Performance improvements.
  •  The ability to easily use components developed in other languages. 
  • Extensible types provided by a class library. 
  • Language features such as inheritance, interfaces, and overloading for object-oriented programming. Support for explicit free threading that allows creation of multithreaded, scalable applications. Support for structured exception handling. 
  • Support for custom attributes.
  •  Garbage collection. Use of delegates instead of function pointers for increased type safety and security.
Question 2 ) What is Garbage Collector ?
Answer 
.NET's garbage collector manages the allocation and release of memory for your application. Each time you create a new object, the common language runtime allocates memory for the object from the managed heap. As long as address space is available in the managed heap, the runtime continues to allocate space for new objects. However, memory is not infinite. Eventually the garbage collector must perform a collection in order to free some memory. The garbage collector's optimizing engine determines the best time to perform a collection, based upon the allocations being made. When the garbage collector performs a collection, it checks for objects in the managed heap that are no longer being used by the application and performs the necessary operations to reclaim their memory. 

Garbage Collector is used in dot net Framework for memory management. While running an application, applications make a request for memory for its internal use. Framework allocates memory from the heap. Once the process is completed, allocated memory needs to be reclaimed for future use. The process of reclaiming unused memory is taken care by the Garbage Collector.


Question 3) What is MS-IL (Microsoft Intermediate Language) 
Answer - 
MSIL stands for Microsoft Intermediate Language. We can call it as Intermediate Language (IL) or Common Intermediate Language (CIL). During the compile time , the compiler convert the source code into Microsoft Intermediate Language (MSIL) .Microsoft Intermediate Language (MSIL) is a CPU-independent set of instructions that can be efficiently converted to the native code. During the runtime the Common Language Runtime (CLR)'s Just In Time (JIT) compiler converts the Microsoft Intermediate Language (MSIL) code into native code to the Operating System. When a compiler produces Microsoft Intermediate Language (MSIL), it also produces Metadata. The Microsoft Intermediate Language (MSIL) and Metadata are contained in a portable executable (PE) file . Microsoft Intermediate Language (MSIL) includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations.



Question 4) What is Common Type System (CTS) ?
Answer
.Net uses Common Type System (CTS) for Language Interoperability. CTS defines the predefined data types that are available in IL, so that all languages that target the .NET framework will produce the compiled code that is ultimately based on these types. CTS ensures that a data type defined in a VB.net will be understood by C#. For example, VB.Net uses “Integer” to define the data type Integer. C# uses  “int” to define the data type Integer. When VB.Net code is compiled, it will convert the Integer to Int32. Since C# refers Int to Int32, VB.Net code will be understood by C#.

Question 5 ) What is Common Language Specification (CLS) ?
Answer
Common Language Specification (CLS) is used for Language Interoperability in tandem with CTS to ensure the interoperability of the languages. CLS defines a set of minimum standards that all compilers targeting dot net must support. For example, VB.Net is not case sensitive. So attribute “EmployeeName” and “employeename” is considered same. But C# is case sensitive. So for language interoperability, C# doesn't allow two variables which differ only in case.

You may also like






No comments :

Post a Comment