Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes about exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "about exception" Watch "about exception" New topic

about exception

wei liu
Ranch Hand

Joined: Dec 06, 2001
Posts: 56
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
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.
Vikrama Sanjeeva
Ranch Hand

Joined: Sep 02, 2001
Posts: 756
I don't think that these types of question will be asked in Exam.
Count the flowers of ur garden,NOT the leafs which falls away!

Count the flowers of your garden, NOT the leafs which falls away!
Prepare IBM Exam 340 by joining
I agree. Here's the link:
subject: about exception
Similar Threads
How to check server is up ? Connection timed out
Initial design review
connect exception