exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 1 question 24 discussion

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

DRAG DROP -
You develop an application that displays information from log files when errors occur. The application will prompt the user to create an error report that sends details about the error and the session to the administrator.
When a user opens a log file by using the application, the application throws an exception and closes.
The application must preserve the original stack trace information when an exception occurs during this process.
You need to implement the method that reads the log files.
How should you complete the relevant 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:
✑ StringReader - Implements a TextReader that reads from a string.
✑ StreamReader - Implements a TextReader that reads characters from a byte stream in a particular encoding.
Once an exception is thrown, part of the information it carries is the stack trace. The stack trace is a list of the method call hierarchy that starts with the method that throws the exception and ends with the method that catches the exception. If an exception is re-thrown by specifying the exception in the throw statement, the stack trace is restarted at the current method and the list of method calls between the original method that threw the exception and the current method is lost. To keep the original stack trace information with the exception, use the throw statement without specifying the exception.
References:
http://msdn.microsoft.com/en-us/library/system.io.stringreader(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/system.io.streamreader(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/ms182363(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
SvM
Highly Voted 5 years, 8 months ago
Apparently: using(StreamReader sr = new StreamReader(...)) StringReader reads from String, not from file
upvoted 10 times
...
natsk8freak
Highly Voted 5 years, 6 months ago
This is correct. When a file is read, imagine a vacuum sucking up the text in the file. This is the StreamReader. The StringReader is like looking at all of the words in the text file, all at once. That's how I remember the difference.
upvoted 8 times
...
merry
Most Recent 4 years, 5 months ago
StreamReader mostly refers to reading files like videos, music, pictures which are usually in bytes. While StringReader mostly refers to reading of text files. This is how I remember he difference.
upvoted 1 times
...
Epit2021
4 years, 7 months ago
The second box is wrong, it should just be throw; as this preserves the stack trace, as per requirements
upvoted 2 times
...
hopewins
4 years, 11 months ago
Imagine the influx of data as a steady stream thus StreamReader(). And throw like another question earlier maintains the stack from the previous use and if we specified an exception the stack will be reset and only contain info for the method it was called.
upvoted 2 times
...
mmarinov
5 years, 1 month ago
Correct. throw; preserves the original stack trace. StreamReader reads from file
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 ...