TCS Papers: Sample Questions 284 - 285 of 502

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 284

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

What is the difference between strings and character arrays?

Explanation

  • A major difference is: string will have static storage duration, whereas as a character array will not, unless it is explicitly specified by using the static keyword.

  • A string is a character array with following properties:

    • The multibyte character sequence is used to initialize an array of static storage.

    • The size of this array is just sufficient to contain these characters plus the terminating ‘NULL’ character.

    • Two strings of same value may share same memory area.

Difference between strings and character arrays

Difference between Strings and Character Arrays

Given the image is define the difference between strings and character arrays

Question number: 285

» Basic CS » Operating System

Essay Question▾

Describe in Detail

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.

Image of the managed code

Image of the Managed Code

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.

Image of the Unmanaged code

Image of the Unmanaged Code

Image of the Unmanaged code