Forums Register Login

about exception

+Pie Number of slices to send: Send
22. There are two computers are connected to internet, one computer is trying to open a socket connection to read the home page of another computer, what are the possible exceptions thrown while connection and reading InputStream?.
A) IOException
B) MalformedURLException
C) NetworkException
D) ConnectException
Answer 22:
A) IOException
B) MalformedURLException
Explanation:
In Java the the URL class will throw "MalformedURLException while construncting the URL, and while reading incoming stream of data they will throw IOException..
-------------
why no ConnectException?
According to java API "public class ConnectException extends SocketException signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the connection was refused remotely (e.g., no process is listening on the remote address/port)."
it seems that ConnectException shoud be fine.
+Pie Number of slices to send: Send
I don't think that these types of question will be asked in Exam.
Bye.
Viki.
------------------
Count the flowers of ur garden,NOT the leafs which falls away!
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 643 times.
Similar Threads
connect exception
How to check server is up ?
Initial design review
java.net.ConnectException: Connection timed out
exception
Re:FTP query
outputstream over the net
can't find an errors but always in connectException
SocketException: Too many open files
java.net.No Route To Host Exception: Operation timed out:
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:47:54.