Can interface throw exception?

K

Ken

Hi.

Can an interface method "throw" an exception? By this, I mean, can an
interface have a method whose signature includes "throws <some
exception>"?

If so, is this available in Java 1.3 and 1.4?

Thanks,

Ken
 
C

Collin VanDyck

Yes, you can certainly have an interface define a method that throws an
exception. This is something that's incredibly easy to

"try and see what happens" (tm).
 
M

Mike Schilling

Ken said:
Hi.

Can an interface method "throw" an exception? By this, I mean, can an
interface have a method whose signature includes "throws <some
exception>"?

If so, is this available in Java 1.3 and 1.4?

Yes, it's been there since Java 1.0, I'm sure. Otherwise it would be
impossible for a method that implements an interface method to throw checked
exceptions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top