wood burning stoves 2.0*
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
Author

deadly diamond of death syndrome :)

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

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.


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: deadly diamond of death syndrome :)