C# Questions & Answers – Network Errors Handling

This section of our 1000+ C# MCQs focuses on networking errors in C# Programming Language.

1. What exception is thrown if the URI format is invalid?
a) URLNotFound
b) URLSourceNotFound
c) MalformedURLException
d) UriFormatException
View Answer

Answer: d
Explanation: None.

2. What exception is thrown if the protocol supported by URI prefix is invalid?
a) URLNotFound
b) URLSourceNotFound
c) UriFormatException
d) NotSupportedException
View Answer

Answer: d
Explanation: None.

3. What exception is thrown if the user does not have a proper authorization?
a) URLNotFound
b) URLSourceNotFound
c) System.Security.SecurityException
d) All of the mentioned
View Answer

Answer: c
Explanation: None.
advertisement
advertisement

4. Choose the exceptions generated by the Create() method defined by WebRequest.
a) NotSupportedException
b) UriFormatException
c) System.Security.SecurityException
d) All of the mentioned
View Answer

Answer: d
Explanation: None.

5. Choose the exceptions generated by the GetReponse() method defined by WebRequest.
a) InvalidOperationException
b) ProtocolViolationException
c) WebException
d) All of the mentioned
View Answer

Answer: d
Explanation: By definition.

6. Select the properties related to the network errors generated by WebException:
a) response
b) get
c) set
d) none of the mentioned
View Answer

Answer: a
Explanation: WebException has two properties that relate to network errors: Response and Status. We can obtain a reference to the WebResponse object inside an exception handler through the Response property. For the HTTP protocol, this object describes the error. It is defined like this:

 public WebResponse Response { get; }

When an error occurs, we can use the Status property of WebException to find out what went wrong. It is defined like this:

advertisement
public WebExceptionStatus Status {get; }

7. Which of these classes is used for operating on the request from the client to the server?
a) http
b) httpDecoder
c) httpConnection
d) httpd
View Answer

Answer: d
Explanation: None.
advertisement

8. Choose the exceptions generated by the GetResponseStream() method defined by WebRequest.
a) ProtocolViolationException
b) ObjectDisposedException
c) IOException
d) All of the mentioned
View Answer

Answer: d
Explanation: None.

9. Which of these classes is used to create servers that listen to either local or remote client programs?
a) httpServer
b) ServerSockets
c) MimeHeader
d) HttpResponse
View Answer

Answer: b
Explanation: None.

10. Which of these methods gives the full URL of an URL object?
a) fullHost()
b) getHost()
c) AbsoluteUri
d) toExternalForm()
View Answer

Answer: c
Explanation: None.

Sanfoundry Global Education & Learning Series – C# Programming Language.

To practice all areas of C# language, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.