exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 2 question 41 discussion

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

You are troubleshooting an application that uses a class named FullName. The class is decorated with the DataContractAttribute attribute. The application includes the following code. (Line numbers are included for reference only.)

You need to ensure that the entire FullName object is serialized to the memory stream object.
Which code segment should you insert at line 09?

  • A. binary.WriteEndDocument();
  • B. binary.WriteEndDocumentAsync();
  • C. binary.WriteEndElementAsync();
  • D. binary.Flush();
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
✑ DataContractSerializer.WriteEndObject Method (XmlDictionaryWriter)
Writes the closing XML element using an XmlDictionaryWriter.
✑ Note on line 07: DataContractSerializer.WriteObject Method
Writes all the object data (starting XML element, content, and closing element) to an XML document or stream.

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, 10 months ago
I'm not sure, but for me the correct answer is: D I think, the question is about how to ensure, that all data is completely written to the underlying stream, not to ensure every XML tag is closed. Therefore the buffer has to be flushed to the memory stream (see https://docs.microsoft.com/de-de/dotnet/framework/wcf/samples/datacontractserializer-sample … in the lower half is an example, where the DataContractSerializer uses a different writer)
upvoted 22 times
...
peter1994
Highly Voted 5 years, 7 months ago
D is the correct answer. You need to flush the remaining bytes if any. Streams work with bytes in chunks so if the remaining bytes aren't yet a chunk, they won't get written if you don't flush them.
upvoted 6 times
...
DaGrooveNL
Most Recent 4 years, 3 months ago
FINAL ANSWER: D.
upvoted 2 times
...
noussa
4 years, 3 months ago
Guys read the requirement: "You need to ensure that the entire FullName object is serialized to the memory stream object." it's just talking about serializing the object but Flush() is more then that. This is MS doc definition: You need to ensure that the entire FullName object is serialized to the memory stream object. So I think A will do the job if it's just serializing the object to the stream but it won't work without a Flush(). So A is just a part of the correct answer. In the Exam there is no Flush() by the way. Hope it helps.
upvoted 2 times
noussa
4 years, 3 months ago
// Use the writer to write the end element and // the end of the document. writer.WriteEndElement(); writer.WriteEndDocument(); // Close and release the writer resources. writer.Flush(); fs.Flush(); fs.Close(); From MS docs too, Full link: https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.datacontractserializer.writeendobject?view=net-5.0
upvoted 1 times
noussa
4 years, 3 months ago
This is a test sample: https://dotnetfiddle.net/yzau8k A is correct but incomplete. If you find flush() in the exam use it otherwise use A
upvoted 3 times
...
...
...
Rover
4 years, 5 months ago
I just wrote the test console application. It doesn't work without binary.Flush(). And (A) answer doesn't help.
upvoted 1 times
...
DiegoB
4 years, 8 months ago
just done the exam yesterday, flush doesnt come as an answer, I used A
upvoted 4 times
Markies
4 years, 7 months ago
D is correct; use completely finished writing, binary.Close() be used instead, refer to: https://docs.microsoft.com/en-us/dotnet/api/system.xml.xmlwriter.flush?view=netframework-4.8
upvoted 1 times
...
...
Alchemia
4 years, 10 months ago
Based on the example https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.datacontractserializer.writeendobject?view=netcore-3.1 D is the correct answer
upvoted 2 times
Alchemia
4 years, 10 months ago
Furthermore the explenation of the answer states this: ✑ Note on line 07: DataContractSerializer.WriteObject Method Writes all the object data (starting XML element, content, and closing element) to an XML document or stream. A is not required.
upvoted 2 times
...
...
Sully_2020
5 years ago
The correct answer is D, binary.Flush(); (see the C# code example located on https://docs.microsoft.com/en-us/dotnet/framework/wcf/samples/datacontractserializer-sample ) -> By default, the DataContractSerializer encodes objects into a stream using a textual representation of XML. However, you can influence the encoding of the XML by passing in a different writer. The sample creates a binary writer by calling CreateBinaryWriter. It then passes the writer and the record object to the serializer when it calls WriteObjectContent. Finally, the sample flushes the writer ...
upvoted 6 times
...
ryuzai
5 years, 3 months ago
stream object will be use flush. That's why correct answer is D.
upvoted 3 times
...
Gods_Kenny
5 years, 5 months ago
A is the correct answer
upvoted 3 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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago