File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes deadly diamond of death syndrome :) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "deadly diamond of death syndrome :)" Watch "deadly diamond of death syndrome :)" New topic

deadly diamond of death syndrome :)

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 808

Please, have a look:

The second one:

Compiler allows you to declare the common exception from within multiple interfaces. If the interfaces' exceptions are uncommon you will not be allowed to declare any checked exception.

I only wanted to figure this out.
Correct me if I am wrong.

Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

That makes sense

For common exception hierarchies

If InterfaceC is allowed to throw IOException then a statement like InterfaceB ref = new SubClassThatThrowsIOExAndImplementsC(); will get into trouble since the Exception scope does not allow this. IOException is wider than FileNotFoundException and the InterfaceB contract only allows you to throw FileNotFoundException

So InterfaceC can only throw FileNotFoundException

For the scenario

InterfaceC is in trouble. For case

So InterfaceC cannot throw anything, since the contract provided by InterfaceA or InterfaceB can be broken

Does that make sense ?

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
I agree. Here's the link:
subject: deadly diamond of death syndrome :)
It's not a secret anymore!