Exam 70-483 Topic 4 Question 112 Discussion

Actual exam question for Microsoft's 70-483 exam
Question #: 112
Topic #: 4
You are creating an application that manages information about your company's products. The application includes a class named Product and a method named Save.
The Save() method must be strongly typed. It must allow only types inherited from the Product class that use a constructor that accepts no parameters.
You need to implement the Save() method. Which code segment should you use?

Suggested Answer: D Vote an answer

Explanation
The condition new() ensures the empty/default constructor and must be the last condition.
When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates your class. If client code tries to instantiate your class by using a type that is not allowed by a constraint, the result is a compile-time error. These restrictions are called constraints.
Constraints are specified by using the where contextual keyword.
http://msdn.microsoft.com/en-us/library/d5x73970.aspx

by Rory at Jan 19, 2025, 02:26 AM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10