Difficulty: Easy
Correct Answer: 1, 2, 3
Explanation:
Introduction / Context:
.NET uses a two-stage compilation model. Source code is compiled into Intermediate Language (IL), then Just-In-Time (JIT) compilation turns IL into native machine code when methods are first executed. Understanding what is compiled when, and where that code runs, is a common exam topic.
Given Data / Assumptions:
The statements are:
Concept / Approach:
JIT compilation occurs at runtime on demand. When a method is first invoked, the JIT converts its IL into native machine code suitable for the current processor/OS. That native code executes under the supervision of the CLR (which provides services like security checks and GC coordination). JIT does not produce IL—that already exists from the earlier compile step—and methods are not JIT-compiled unless they are invoked (or unless a specific ahead-of-time or pre-jitting mechanism is used).
Step-by-Step Solution:
Evaluate 1 → True: JIT happens at runtime.Evaluate 2 → True: JITted native code executes in the CLR-managed environment.Evaluate 3 → True: Output is native machine code.Evaluate 4 → False: JIT consumes IL; it does not produce IL.Evaluate 5 → False: Standard JIT compiles on first use, not for unused methods.
Verification / Alternative check:
Inspect a profiler or JIT event logs: methods are compiled upon first call; unused methods remain unjitted.
Why Other Options Are Wrong:
Options containing 4 or 5 include incorrect claims about IL output or compiling unused methods.
Common Pitfalls:
Confusing JIT with IL generation by the language compiler, or assuming eager compilation of all methods.
Final Answer:
1, 2, 3
Discussion & Comments