MCTS - Microsoft Certified Technology Specialist .NET Application Development Questions and Answers 1 — Questions and Answers
Question 1: A developer needs to ensure that a compiled .NET assembly can be shared across multiple applications on a single machine. Which of the following is a mandatory prerequisite for deploying an assembly to the Global Assembly Cache (GAC)?
- The assembly must be digitally signed with a code signing certificate.
- The assembly must be compiled in Release mode.
- The assembly must have a strong name. (Correct answer)
- The assembly must be registered using the regasm.exe tool.
Correct answer: The assembly must have a strong name.
To be installed in the Global Assembly Cache (GAC), an assembly must have a strong name. A strong name consists of the assembly's identity—its simple text name, version number, and culture information (if provided)—plus a public key and a digital signature. This ensures the uniqueness of the assembly and prevents conflicts.
Question 2: In the context of the .NET garbage collector, which generation is collected most frequently and contains newly allocated, short-lived objects?
- Generation 1
- Generation 2
- Generation 0 (Correct answer)
- The Large Object Heap (LOH)
Correct answer: Generation 0
The .NET garbage collector uses a generational approach to optimize performance. New objects are allocated in Generation 0. The GC collects Generation 0 most frequently because most objects are short-lived and can be reclaimed quickly. Objects that survive a Generation 0 collection are promoted to Generation 1, and those that survive a Generation 1 collection move to Generation 2.
Question 3: A developer is building an ASP.NET Web Forms application and needs to programmatically create and add dynamic controls to a page. In which of the following page life cycle events is it most appropriate to create these controls to ensure their view state is correctly managed on subsequent postbacks?
- Load
- PreRender
- PreInit (Correct answer)
- Render
Correct answer: PreInit
The PreInit event is the earliest stage in the page life cycle where it is appropriate to create dynamic controls. Creating controls this early ensures they are part of the page's control tree and can properly participate in the rest of the life cycle, including the loading of view state and postback data.
Question 4: What is the primary role of the Common Intermediate Language (CIL) in the .NET Framework?
- To provide a set of base classes for application development.
- To directly execute code on the CPU without any further compilation.
- To serve as a common, platform-independent instruction set that all .NET languages compile into. (Correct answer)
- To manage memory allocation and garbage collection for managed code.
Correct answer: To serve as a common, platform-independent instruction set that all .NET languages compile into.
Common Intermediate Language (CIL), formerly known as MSIL, is the low-level, platform-independent instruction set into which all .NET source code (from languages like C#, VB.NET, etc.) is compiled. This CIL code is later compiled into native machine code by the Just-In-Time (JIT) compiler at runtime, enabling language interoperability and platform independence.
Question 5: You are developing a Windows Presentation Foundation (WPF) application and need to define a custom property for a UserControl that supports data binding, styling, and animation. Which type of property should you implement?
- A static property on the control class.
- A standard CLR property with a backing field.
- An attached property.
- A dependency property. (Correct answer)
Correct answer: A dependency property.
Dependency properties are a specific type of property system provided by WPF. They are required for a property to support features like data binding, styling, animation, and property value inheritance. Standard CLR properties do not have this built-in infrastructure.
Question 6: A developer is working on a data access layer using ADO.NET and needs to work with a disconnected, in-memory representation of data retrieved from a database. Which ADO.NET object is best suited for this scenario?
- DataReader
- DataSet (Correct answer)
- DbCommand
- DbConnection
Correct answer: DataSet
The DataSet is designed specifically for disconnected data access. It can hold multiple tables, relationships, and constraints, all in memory. This allows an application to retrieve data from a source, close the connection, and then work with the data locally before potentially reconnecting to update the source. A DataReader, in contrast, provides a forward-only, connected stream of data.
A developer needs to ensure that a compiled .NET assembly can be shared across multiple applications on a single machine.
Which of the following is a mandatory prerequisite for deploying an assembly to the Global Assembly Cache (GAC)?