nerdexam
Microsoft

98-372 · Question #102

Which of the following is an accurate description of generics?

The correct answer is D. A class using placeholders for one or more of the types it uses. Generics make use of placeholders for their types, which permit multiple types of objects to be used as a parameter. The .NET Framework version has provided a new feature of generics that introduce to the .NET Framework the concept of type parameters, which make it possible to…

Understanding Data Types and Collections

Question

Which of the following is an accurate description of generics?

Options

  • AA type minimizing the reusability of code and type safety
  • BA type storing a pointer to the data, instead of the actual data
  • CA class enabling the compiler to catch type-casting errors during runtime
  • DA class using placeholders for one or more of the types it uses

How the community answered

(20 responses)
  • A
    5% (1)
  • B
    5% (1)
  • C
    10% (2)
  • D
    80% (16)

Explanation

Generics make use of placeholders for their types, which permit multiple types of objects to be used as a parameter. The .NET Framework version has provided a new feature of generics that introduce to the .NET Framework the concept of type parameters, which make it possible to design classes and methods that postpone the specification of one or more types until the class or method is declared and instantiated by client code. For instance, by using a generic type parameter T, a single class can be written that other client code can exploit without incurring the cost or risk of runtime casts or boxing operations. The following are the benefits of using generics: 1.Generic types are used to maximize the reusability of code, type safety, and performance of .NET applications. 2.Generics are used to create new generic collection classes contained in the System.Collections.Generic namespace. 3.Custom generics can be created that include generic interfaces, classes, methods, events and 4.The type information used in a generic data type can be obtained by reflection during runtime. 5.Generics enable the compiler to catch type-casting errors during compilation. 6.Generics do not require casting or boxing, and therefore, it improves runtime performance.

Topics

#generics#type parameters#type safety#reusability

Community Discussion

No community discussion yet for this question.

Full 98-372 Practice