exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 1 question 9 discussion

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

You are developing an application. The application converts a Location object to a string by using a method named WriteObject. The WriteObject() method accepts two parameters, a Location object and an XmlObjectSerializer object.
The application includes the following code. (Line numbers are included for reference only.)

You need to serialize the Location object as a JSON object.
Which code segment should you insert at line 20?

  • A. New DataContractSerializer(typeof(Location))
  • B. New XmlSerializer(typeof(Location))
  • C. New NetDataContractSenalizer()
  • D. New DataContractJsonSerializer(typeof(Location))
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️
The DataContractJsonSerializer class serializes objects to the JavaScript Object Notation (JSON) and deserializes JSON data to objects.
Use the DataContractJsonSerializer class to serialize instances of a type into a JSON document and to deserialize a JSON document into an instance of a type.

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
andyrays
Highly Voted 5 years ago
For those confused like me: DataContractSerializer and DataContractJsonSerializer both inherit from the abstract base class XmlObjectSerializer. However, DataContractJsonSerializer outputs JSON, while DataContractSerializer outputs XML. Therefore DataContractJsonSerializer is the correct answer.
upvoted 7 times
mameenkhn
4 years, 8 months ago
This is the correct reason. This is what we call Polymorphism in Object Oriented.
upvoted 2 times
...
...
zzMichielzz
Most Recent 4 years, 9 months ago
D. Json + DataContract =>DataContractJsonSerializer
upvoted 2 times
...
ebao
4 years, 9 months ago
The answer should be A because the question says [DataContract]
upvoted 1 times
ebao
4 years, 9 months ago
sorry i am wrong. D is correct.
upvoted 1 times
...
...
lh2607
5 years ago
D is correct
upvoted 1 times
...
robinnirola
5 years, 2 months ago
Ans D: New DataContractJsonSerializer(typeof(Location)) it is asking for Json so Ans D is for JSon Object
upvoted 1 times
...
ArunPrem
5 years, 7 months ago
The questions says "The WriteObject() method accepts two parameters, a Location object and an XmlObjectSerializer object." but the answer is given as D which is DataContractJsonSerializer. Both the DataContractJsonSerializer and the DataContractSerializer has the ReadObject and WriteObject. So here the question has an ambiguity.
upvoted 2 times
mendolf92
5 years, 5 months ago
But its pointed out: "You need to serialize the Location object as a JSON object", therefore the result is D because the DataContractSerializer would return a xml
upvoted 9 times
...
tanujgyan
5 years, 3 months ago
Exactly DataContractJsonSerializer - JSON DataContractSerializer - XML
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 ...