MCQ

C# MCQ – Multiple Choice Questions and Answers – Part 3

Multiple choice questions and answers (MCQs) on C# to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are taken from an interview. So you will find questions on basic techniques such as Variables, Operators, Conditional Statement, Functions, and more. This quiz will easily prepare anyone to pass their online test.
 

 

1. Which can be used to compile managed assemblies into native processor-specific code?

A gacutil

B ngen

C sn

D dumpbin

E ildasm

B
Ngen.exe is a tool that improves the performance of managed applications. Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them in the local computer’s cache. The runtime engine can use native images from the cache instead of using the JIT (Just-in-Time) compiler to compile the original assembly.

 

 

2. Which of the following statements is correct about managed code?

A The managed code is the code compiled by the JIT compilers.

B Managed code is the code in which resources are fetched.

C Managed code is code that runs on Windows.

D Managed code is code written to target CLR services.

E Managed code is code that can be executed on Linux.

D
Managed code is code that is managed by the Common Language Runtime. It gets the managed code and compiles it into machine code. After that, the code is executed.

 

 

3. Which of the following statements are NOT true about the .NET Framework ?

A It provides a consistent object-oriented programming environment, whether the object code is stored and executed locally, but distributed over the Internet or executed remotely.

B It provides a code execution environment that minimizes software deployment and version conflicts.

C It provides a code execution environment that promotes secure execution of code, including code created by an unknown or semi-reliable third party.

D It provides different programming models for Windows and Web applications.

E It provides an event-driven programming model for building Windows device drivers.

D, E

 

 
 

4. Which of the following .NET Framework components provide an extensible set of classes that can be used by any .NET compatible programming language?

A .NET Framework class library

B Common Language Runtime (CLR)

C Common Language Infrastructure (CLI)

D Component Object Model (COM)

E Common Type System (CTS)

A
The .NET Framework class library is a library of classes, interfaces and value types that provide access to system functionality.

 

 

5. Which of the following jobs are NOT performed by Garbage Collector?

A Free up memory on the stack.

B Avoid memory leaks.

C Release of memory occupied by non-referenced objects.

D Closing unclosed database collections.

E Closing unclosed files.

A, D, E
The Garbage collector manages the allocation and reclamation of memory. GC works on the managed heap, which is nothing but a block of memory for storing objects. There are no specific timings for the GC to be triggered, the GC starts automatically. Managed objects are created and managed under the scope of the CLR.

 

 

6. Which of the following .NET components can be used to remove unused references from memory in the managed heap?

A Common Language Infrastructure

B Class Loader

C Garbage Collector

D CLR

E CTS

C
The Garbage collector manages the allocation and reclamation of memory. GC works on the managed heap, which is nothing but a block of memory for storing objects. There are no specific timings for the GC to be triggered, the GC starts automatically. Managed objects are created and managed under the scope of the CLR.

 

 

7. Which of the following statements correctly defines the .NET framework?

A It is an environment for developing, creating, deploying and running desktop applications, web applications and web services.

B It is an environment for developing, building, deploying and running only Web applications.

C It is an environment for developing, creating, deploying and running distributed applications.

D It is an environment for developing, creating, deploying and running Web services.

E It is an environment for developing and running Windows applications.

A

 

 
 

8. Which of the following is the .NET framework ?

A ASP.NET Applications

B .NET Framework class library

C WinForm Applications

D Windows Services

E CLR

A, B

 

 

9. Which of the following assemblies can be stored in the Global Assembly Cache?

A Private Assemblies

B Friend Assemblies

C Shared Assemblies

D Public Assemblies

E Protected Assemblies

C
Shared assembly is an assembly that lives in a centralized location called GAC (Global Assembly Cache) and provides resources to multiple applications. If an assembly is shared, multiple copies will not be created even if they are used by multiple applications. The GAC folder is located under the Windows folder.
 

 

 

10. The code that targets the Common Language Runtime(CLR) is called _____?

A Unmanaged

B Distributed

C Inheritance

D Managed code

E Native code
 

 
D
Managed code is code whose execution is managed by Common Language Runtime. It retrieves the managed code and compiles it into machine code.

 

 
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *