This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a question about catch exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "a question about catch exception" Watch "a question about catch exception" New topic
Author

a question about catch exception

feng lee
Ranch Hand

Joined: Oct 29, 2002
Posts: 33
if a method throws an ProtocolException(subclass of IOException) which of the following can be used in declaring that method
a. public void method() throws Exception
b. public void method() throw Exception
c. public throws IOException void method()
d. public void method() throws IOException.
e. public void method() throws ProtocolException.
an ,e.Why a is not right?
Don Bosco
Ranch Hand

Joined: Oct 31, 2002
Posts: 108
Originally posted by feng lee:
if a method throws an ProtocolException(subclass of IOException) which of the following can be used in declaring that method
a. public void method() throws Exception
b. public void method() throw Exception
c. public throws IOException void method()
d. public void method() throws IOException.
e. public void method() throws ProtocolException.
an ,e.Why a is not right?

u bet. a,d and e are correct.


SCJP 1.4<p>Wingardium Leviosa!!
Steve Leung
Greenhorn

Joined: Dec 05, 2002
Posts: 3
Hello,
It seems depend on the method we implement is override the a method or superclass of that class. If we implement subclass of that class, only e is valid.


SCJP 1.4
Shanmugam Karthikeyan
Ranch Hand

Joined: Aug 02, 2002
Posts: 58
Hello please explain it clearly...

i cound't understand your answer
if possible , state some example which justifies your arguments


SCJP 1.4<br />SCWCD 1.4<br />SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a question about catch exception