exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 2 question 119 discussion

Actual exam question from Microsoft's 70-483
Question #: 119
Topic #: 2
[All 70-483 Questions]

DRAG DROP -
You are creating a class named Data that includes a dictionary object named _data.
You need to allow the garbage collection process to collect the references of the _data object.
You have the following code:

Which code segments should you include in Target 1 and Target 2 to complete the code? (To answer, drag the appropriate code segments to the correct locations in the answer area. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.)
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
WeakReference influences the garbage collector. Most objects that are referenced must be kept in memory until they are unreachable. But with WeakReference, objects that are referenced can be collected.
Example: C# program that uses WeakReference
using System;
using System.Text;
class Program
{
/// <summary>
/// Points to data that can be garbage collected any time.
/// </summary>
static WeakReference _weak;
static void Main()
{
// Assign the WeakReference.
_weak = new WeakReference(new StringBuilder("perls"));
Reference: http://www.dotnetperls.com/weakreference

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Mitsoshima
Highly Voted 5 years, 11 months ago
Correct answer is: 1 and 3
upvoted 25 times
...
WasifBhatti
Most Recent 4 years, 11 months ago
a and c
upvoted 2 times
...
asdf652434
5 years, 8 months ago
adding should probably look like this: _data.Add(i, new WeakReference(new Data(i), false)); (new Class(i) makes not much sense with the given information)
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.

SaveCancel
Loading ...