C# Programming - .NET Framework - Discussion

Discussion :: .NET Framework - General Questions (Q.No.1)


Which of the following statements are TRUE about the .NET CLR?

  1. It provides a language-neutral development & execution environment.
  2. It ensures that an application would not be able to access memory that it is not authorized to access.
  3. It provides services to run "managed" applications.
  4. The resources are garbage collected.
  5. It provides services to run "unmanaged" applications.

[A]. Only 1 and 2
[B]. Only 1, 2 and 4
[C]. 1, 2, 3, 4
[D]. Only 4 and 5
[E]. Only 3 and 4

Answer: Option C


No answer description available for this question.

Praveen Saini said: (Jun 17, 2011)  
This option is absolutly right bcoz CLR is the only one who is responsible to run the managed code and denied to run the unmanaged/Non-cls complient code.

Geetha said: (Jul 16, 2011)  
How come the resources are garbage collected ?

Sushma said: (Jul 23, 2011)  
How resources are garbage collected?

Navnath said: (Aug 10, 2011)  
CLR provides run time services.

Ann said: (Aug 19, 2011)  
Its the work of the dispose () method to free the resources that are not in use. The dispose method is present in the garbage collector.

Himanshu said: (Sep 19, 2011)  
1, 2, 3, 4 all these points are the services of CLR.

That's why option c is right.

Ankur Bindra said: (Oct 8, 2011)  
CLR converts source code to an intermediate code which is further executed by JIT compiler.

Venkatesh said: (Dec 22, 2011)  
How could be the option 2 will be right ?

Raja A said: (Jan 9, 2012)  
@venkadesh: me too having same doubt?

Shruthi said: (Jan 13, 2012)  
It provides a code which is machine independent thats why 1st opt is right, it provides thight security thats why 2nd opt is right, CLR runs nly managed code so 3rd opt is right, and it has automatic garbage collection so 4rth opt is right.

Abhishek said: (Jan 15, 2012)  
I think option 2 is some what not reletive as how come it will restrict the memory occupancy of other object. (Might be type safety thing would be there).

Xyz said: (Jan 18, 2012)  
The runtime automatically handles object layout and manages references to objects, releasing them when they are no longer being used. Objects whose lifetimes are managed in this way are called managed data. Garbage collection eliminates memory leaks as well as some other common programming errors. If your code is managed, you can use managed data, unmanaged data, or both managed and unmanaged data in your .NET Framework application. Because language compilers supply their own types, such as primitive types, you might not always know (or need to know) whether your data is being managed.

Prashant said: (Apr 2, 2012)  
These are the basic features of CLS in .Net framework. So the given answer is absolutely right.

Praful Godhankar said: (May 31, 2012)  
The CLR provides Language compatibility to developed applications in .Net

Ranjeet said: (Jul 12, 2012)  
CLR convert source to an intermidiate code that is further executed by JIT compiler.

Suresh said: (Jul 23, 2012)  
The option C is Correct, because the code run on the CLR is called Managed Code.

Robin said: (Jul 23, 2012)  
The CLR provide language compatibility to developed application in .Net.

Inceptos said: (Jul 30, 2012)  
CLR provides the following:

1. Modern memory management- the resources are automatically garbage collected.

2. Ability to use mixed languages.

3. Better security.

4. Clean way for software components to interact.

Managed code is executable under CLR.

Shyam said: (Oct 1, 2012)  
Ability to use mixed languages.

Mohit Bansal said: (Nov 1, 2012)  
CLR is responsible for all the execution of .Net framework. So it execute the native code.

Rahul said: (Nov 9, 2012)  
CLR only provide compile & execute the program so option number c right because Operation 1 to 4 every action perform by .Net CLR Compiler.

Vin2 said: (Feb 23, 2013)  
It provides a code which is machine independent that's why 1st option is right, it provides tight security that's why 2nd option is right, CLR runs only managed code so 3rd option is right, and it has automatic garbage collection so 4rth option is right.

Piyush said: (Mar 24, 2013)  
What is the meaning of manged applications?which type of applications are said to be managed application?

Veyronash said: (Apr 10, 2013)  
Managed applications are those that contains managed code that are directly executed by CLR and these codes have CLR services like type checking, safety and automatic garbage collection.

Abhishek Barbadikar said: (May 7, 2013)  
These are four main features of CLR.

Hussainbasha said: (May 9, 2013)  
1. Cross-language integration, especially cross-language inheritance.

2. Garbage collection, which manages object lifetime so that reference counting is unnecessary.

3. Garbage collection.

Umesh said: (May 17, 2013)  
What is native code?

Gaurav said: (Jun 13, 2013)  
Native code is code that's generated after IL code, its depended to environment e.g winxp, win7 32bit, 64 bit.

Rahul said: (Jul 9, 2013)  
Native code is machine language code.

Babar said: (Jul 15, 2013)  
Code that is understand by Operating system, we can say machine code.

Sugath said: (Oct 15, 2013)  
Managed Code:

Managed code is code that is written to target the services of the managed runtime execution environment (like Common Language Runtime in .NET Framework). The managed code is always executed by a managed runtime execution environment rather than the operating system directly. Managed refers to a method of exchanging information between the program and the runtime environment. Because the execution of code is governed by the runtime environment, the environment can guarantee what the code is going to do and provide the necessary security checks before executing any piece of code. Because of the same reason the managed code also gets different services from the runtime environment like Garbage Collection, type checking, exception handling, bounds checking, etc. This way managed code does not have to worry about memory allocations, type safety, etc. Applications written in Java, C#, VB.NET, etc target a runtime environment which manages the execution and the code written using these types of languages is known as Managed Code. Managed code is always compiled into an Intermediate Language (MSIL in case of .NET Framework). The compiler used by .NET framework to compile managed code compiles it into Intermediate Language and generates the necessary metadata, symbolic information that describes all of the entry points and the constructs exposed in the Intermediate Language (e.g., methods, properties) and their characteristics. The Common Language Infrastructure (CLI) Standard describes how the information is to be encoded, and programming languages that target the runtime emit the correct encoding.

In .NET Framework Managed Code runs within the .Net Framework's CLR and benefits from the services provided by the CLR. When we compile the managed code, the code gets compiled to an intermediate language (MSIL) and an executable is created. When a user runs the executable the Just In Time Compiler of CLR compiles the intermediate language into native code specific to the underlying architecture. Since this translation happens by the managed execution environment (CLR), the managed execution environment can make guarantees about what the code is going to do, because it can actually reason about it. It can insert traps and sort of protection around, if it's running in a sandboxed environment, it can insert all the appropriate garbage collection hooks, exception handling, type safety, array bounce, index checking and so forth.

Managed code also provides platform independence. As the managed code is first compiled to intermediate language, the CLR's JIT Compiler takes care of compiling this intermediate language into the architecture specific instructions.
Unmanaged Code

Code that is directly executed by the Operating System is known as un-managed code. Typically applications written in VB 6.0, C++, C, etc are all examples of unmanaged code. Unmanaged code typically targets the processor architecture and is always dependent on the computer architecture. Unmanaged code is always compiled to target a specific architecture and will only run on the intended platform. This means that if you want to run the same code on different architecture then you will have to recompile the code using that particular architecture. Unmanaged code is always compiled to the native code which is architecture specific. When we compile unmanaged code it gets compiled into a binary X86 image. And this image always depends on the platform on which the code was compiled and cannot be executed on the other platforms that are different that the one on which the code was compiled. Unmanaged code does not get any services from the managed execution environment.

In unmanaged code the memory allocation, type safety, security, etc needs to be taken care of by the developer. This makes unmanaged code prone to memory leaks like buffer overruns and pointer overrides and so forth.

Unmanaged executable files are basically a binary image, x86 code, loaded into memory. The program counter gets put there and that's the last the Operating System knows. There are protections in place around memory management and port I/O and so forth, but the system doesn't actually know what the application is doing.

Milu said: (Feb 1, 2014)  
The code which is runs under the .Net framework that is managed code & it provides security, reusability, portability and automatic memory management that's it.

Shukur said: (Mar 5, 2014)  
What is IL code ?

Govindu said: (Mar 6, 2014)  
il code is a half compile code,il code generated after compile source code. jit compile genarate machine code(processor understandable code like 1 and 0's) from il code when the program execute.

Sud said: (Sep 5, 2014)  
What is difference between CLR and CLS?

Dev said: (Sep 11, 2014)  
CLR is convert MSIL [{Microoft intermediate Language (Assemblies)] means ASCII code not a m/c code}], Code into M/c code directly and will not produce produce M/c Code file.

Sampat said: (Jan 7, 2015)  
CLR is Execution engine of .net Framework. Managed code is targeted to MSIL code.

Mohan said: (Feb 4, 2015)  
What is mean by managed code & unmanaged code?

Nicholas Mahbouby said: (Mar 26, 2015)  
Managed objects of reference type are garbage collected. Resources (e.g File or database connection) are not. That is why classes that wrap them should implement ID is possible.

Ashish said: (Jul 7, 2015)  
CLR is Common Language Runtime.

Venkatesh said: (Jul 21, 2015)  
CLR is an execution environment and it provides to access some memory.

Ritesh Kumar said: (Nov 2, 2015)  
Difference between Int, Int16, Int32 and Int64?

Kaushal said: (Nov 6, 2015)  
CLR is Common Language Runtime: The virtual machine component of Microsoft's .NET framework, manages the execution of .NET programs.

A process known as just-in-time compilation converts compiled code into machine instructions which the computer's CPU then executes.

Ram said: (Feb 9, 2016)  
What is CLS?

Arfab said: (Feb 18, 2016)  
Network is started CLR provides the following:

1. Modern memory management- the resources are automatically garbage collected.

2. Ability to use mixed languages.

3. Better security.

4. Clean way for software components to interact.

Managed code is executable under CLR.

Gardenexit said: (Jun 1, 2016)  
Native code is not a machine code.

.Net languages all converge to IL (intermediate Language) and executed by the runtime, the runtime runs Win32.dll,kernel.dll, ui.dll, etc... which are all COM objects written in C++ in the form of Components and Containers objects (which exist in their C# form also in managed code).

COM Objects are unmanaged code.

But where the answer is wrong, it should be 1,2,3,4 and 5 is you can run unmanaged code from C# compilers, using the unmanaged keyword and using System.

Interop wrappers around the unmanaged code to marshal, say, marshalling method calls and parameter passing into functions in the IDispatch interface of a COM object.

Mazid said: (Sep 27, 2016)  
What do you mean by language neutral development?

Anand Sami said: (Oct 7, 2016)  
CLR provide the managed code.

Ravindra Reddy M said: (Nov 25, 2016)  
That is Correct Answer, CLR Provides Managed Code.

Krishan Chandra Gupta said: (Jun 16, 2017)  
CLR converting Managed code[VB, C#, J#] to native code which is system understandable.
C#-------> [compiler ]--------->IL code----------->[JIT]----------> Native code.
CLR is checking the code is managed code or not,
CLR provide type safety.
It is ensured that an application would not access the memory that is not Authorised to access.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.