exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 1 question 10 discussion

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

You are developing an application by using C#. The application includes the following code segment. (Line numbers are included for reference only.)

The DoWork() method must not throw any exceptions when converting the obj object to the IDataContainer interface or when accessing the Data property.
You need to meet the requirements. Which code segment should you insert at line 07?

  • A. var dataContainer = (IDataContainer)obj;
  • B. dynamic dataContainer = obj;
  • C. var dataContainer = obj is IDataContainer;
  • D. var dataContainer = obj as IDataContainer;
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️
As - The as operator is like a cast operation. However, if the conversion isn't possible, as returns null instead of raising an exception.
References: http://msdn.microsoft.com/en-us/library/cscsdfbt(v=vs.110).aspx

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
pvtpeter
Highly Voted 5 years, 4 months ago
Yes, D is the correct.
upvoted 5 times
...
zzMichielzz
Most Recent 4 years, 8 months ago
D. just like tanjgyan says.. in case of an exception it just returns a null
upvoted 1 times
...
robinnirola
5 years, 1 month ago
Ans D. var dataContainer = obj as IDataContainer;
upvoted 2 times
...
tanujgyan
5 years, 2 months ago
Correct answer is D. "as" doesn't throw an exception when conversion doesn't work
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 ...