Basic CS-Operating System [TCS Placement]: Sample Questions 7 - 8 of 35

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 7

Operating System
Edit

Describe in Detail

Essay▾

Which method does one uses to enforce garbage collection in . NET?

Explanation

  • The System. GC. Collect () method forces garbage collection
  • Garbage collection occurs when one of the following conditions is true:
  • The system has low physical memory.
  • Memory used by allocated objects on the managed heap surpasses an acceptable threshold.
  • Threshold is continuously adjusted as the process runs.
  • The GC. Collect method is called primarily for unique situations and testing.

Question 8

Operating System
Edit

Describe in Detail

Essay▾

Differentiate between managed and unmanaged code?

Explanation

Managed Code:

  • Executed by the CLR instead of the operating system.
  • Code compiler compiles the managed code to intermediate language (IL) code, also called as MSIL code.
  • Code does not depend on machine configurations and can be executed on different machines.
  • The resources within application domain are managed code. These are faster.
  • The code, developed in . NET framework, is known as managed code.
  • Code is directly executed by CLR with help of managed code execution.
  • Any language that is written in . NET Framework is managed code.
  • Managed code uses CLR, which in turns looks after your applications by managing memory, handling security, allowing cross - language debugging, and so on providing uniformity in platform and language- independent behavior of managed code applications.
Given the Code is Define the Managed Code

Unmanaged code

  • Unmanaged code is executed directly by the operating system outside the CLR environment.
  • Directly compiled to native machine code and hence depends on the machine configuration.
  • Since execution of the code is not governed by CLR, the runtime does not provide services, such as garbage collection, type checking, exception handling, and security support. In the unmanaged code, the allocation of memory, type safety, and security has to be taken care of by the developer.
  • If the unmanaged code is not properly handled, it may result in memory leaks and security vulnerabilities.
  • Examples of unmanaged code are ActiveX components and Win32 APIs that execute beyond the scope of native CLR.
The Unmanaged Code

Developed by: