This week's giveaways are in the MongoDB and Jobs Discussion forums. We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line! See this thread and this one for details.
This code compiles fine. I always thought it is not possible to state more than one class after "extends"? interface Int_A {} interface Int_B {} class A{} class B{} class C extends A, B {} interface Test extends Int_A , Int_B {} Appreciate your answers: Thomas
Shishio San
Ranch Hand
Joined: Aug 29, 2002
Posts: 223
posted
0
Hi, You can't extend more than one class but you can implement more than one interface. I think you know that already. The code you posted flags a compile time error when it reaches class C extends A, B {} Maybe you should try to compile it again.
Whatever doesn't kill us ...<br />Is probably circling back for another try.<br />SCJP 1.4
Shishio San
Ranch Hand
Joined: Aug 29, 2002
Posts: 223
posted
0
I forgot to mention that an interface can extend more that one interface.
Kathy Sierra
Cowgirl and Author
Ranch Hand
Joined: Oct 10, 2002
Posts: 1572
posted
0
Interfaces can always extend other interfaces, since this presents no multiple inheritance problem. Whoever first implements an interface must provide implementations for everything in that interface, PLUS, everything in all the superinterfaces (i.e. the interfaces your interface extends, and any that *they* extend, and so on all the way up). Just a side note about one place this is used... This is used especially in EJBs where you might have a business interface (with just business logic) and then a component interface that extends both Remote (which it must, for RMI) and also the business interface. Then your enterprise bean can extend just the business interface and everyone is happy.
Co-Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0596007124/ref=jranch-20" target="_blank" rel="nofollow">"Head First Design Patterns"</a><br /> <br />Just a Jini girl living in a J2EE world.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.