MCQ

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

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. CLR means __________ ?

A Common Local Runtime

B Common Language Runtime

C Common Language Realtime

D Common Local Realtime

B
The CLR (Common Language Runtime) is a runtime environment that is part of the Microsoft .NET Framework. CLR manages the execution of programs written in different supported languages.

CLR transforms the source code into a form of secondary code called CIL (Common Intermediate Language). At runtime, CLR manages the execution of the CIL code.

 

 

2. CLR is responsible for __________ ?

A Garbage-collector

B Code access security

C Code verification

D All the answers are true

D
The CLR (Common Language Runtime) is responsible for the garbage-collector, access security and code verification.

 

 

3. GAC means __________ ?

A Global Assembly Cache

B Global Assembly Store

C Garbage Assemble Cache

D Global Advanced Cache

A
The Global Assembly Cache (GAC) is a folder in the Windows directory (Windows assembly) that stores .NET “assemblies” specifically designated to be shared by all applications running on a system.

The concept of GAC is the result of the .NET architecture which was designed to address the “DLL” problem that existed in COM (Component Object Model). Unlike COM, it is not necessary for the assembly in GAC to be registered before its use. The access to each “assembly” is global, without conflict, by identifying its name, its version, its architecture and its public key.

 

 

4. GAC __________ ?

A Stores .net assemblies shared between several applications.

B Stores global dll’s.

C Caching application data.

D None of the above

A
Global Assembly Cache (GAC) stores the .NET assemblies shared between several applications.

 

 
 

5. What are the types of JIT?

A Pre-JIT

B Econo-JT

C Normal-JIT

D All the answers are true

D
Just-in-time (JIT) is a term used to describe an action such as compiling or activating an object only when it becomes necessary. This term is mainly associated with software compilation. JIT compilation is primarily designed for high-speed code execution and cross-platform support.

JIT compilation was born out of the need for a compiler to take on responsibilities in addition to converting to object code (machine instructions) from a high-level language. JIT compilers facilitate portability to multiple operating systems and hardware platforms. Languages such as Java and C# support JIT compilation.

There are three types of JIT compilers:

  • Pre-JIT: Compiles the entire source code at compile time and is used at deployment time.
  • Econo-JIT: Compiles the methods called at runtime.
  • Normal-JIT: Compiles only the methods called at runtime (at the time of their first call) and stores the compiled code in the cache for use in subsequent calls.

 

 

6. Garbage collector (GC) includes _______ generations.

A One

B Two

C Three

D Five

C
There are three generations:

  • The 0 generation identifies a newly created object that has never been marked for collection.
  • The 1st generation identifies an object that survived a GC (marked for collection but not deleted because there was enough heap space)
  • The 2nd generation identifies an object that has survived more than one GC scan.

 

 

7. How to force the garbage-collector to run?

A Using the method GC.Run()

B Using the method GC.Collect()

C Using the method GC.Collection()

D Using the method GC.Finalize()

B
System.GC.Collect() forces the execution of the garbage-collector.

 

 
 

8. IL in .Net means ________?

A Intermediate Language

B International Language

C Interoperate Language

D Intermediate Local

A
Intermediate language (IL) is an object-oriented programming language designed to be used by compilers for the .NET Framework. The .NET Framework uses IL to generate machine-independent code as the output from compiling source code written in any .NET programming language.

 

 

9. What tool is used to display the IL code?

A Util.exe

B IL.exe

C GACUtil.exe

D IDASM.EXE

D
ILDASM (IL Disassembler) is an excellent tool for those who want to see the IL code. This tool is used to display the contents of the assembly for all code components. This tool is installed with your Visual Studio and can be accessed in the traditional way at the Visual Studio command prompt.

To open the ILDASM:
1- Open the Visual Studio command prompt.
2- Run the ILDASM command.

 

 

10. What does the term “boxing” mean in .net?

A Convert value type to object

B Convert reference type to value type

C Convert the primitive type into a value type

D None of the above
 

 
A
Boxing is the process of converting a value type into an object type or any interface type implemented by that value type. When the CLR boxes a value type, it encapsulates the value in a “System.Object” and stores it in the managed memory segment. Unboxing extracts the value type from the object.

Boxing
int n = 123;
object obj = n;
Unboxing
obj = 123;
i = (int)obj;

The following image shows the result of the previous statements.

 

 
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 *