This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Question on Multiple inheritance using interfaces. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "Question on Multiple inheritance using interfaces." Watch "Question on Multiple inheritance using interfaces." New topic

Question on Multiple inheritance using interfaces.

Tushar Ravi

Joined: Nov 23, 2010
Posts: 10

Hi guys,

I have question on this topic.

I have an interface

another interface

I am implementing the above interfaces in a class

This compiles and runs fine.

I want to know how will this work ? How will the JVM know if the testData() overridden is from or

Many thanks in advance.

fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11855

If your mom said "Go clean your room" and your dad said "go clean your room", do you have to clean your room twice? If you only clean your room once, how does someone know if you did it for your mom or for your dad?

The truth is - it doesn't matter, because doing it once satisfies both parent's requirements - and it's the same here in java and interfaces..

when you say

You're simply saying "I promise that the code I write below will satisfy the requirements of both ViewActions and DataActions." As soon as you write the "public int testData()" method, you have satisfied that part of the requirements for each interface (there could be others, although there is not in your example).

now, IF the two methods with the same name need to to fundamentally different things, you have a design issue.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Tushar Ravi

Joined: Nov 23, 2010
Posts: 10

Awesome reply fred . I liked the way you explained with the example "Go clean your room" .

Thanks a lot.

Vinod Vinu
Ranch Hand

Joined: Aug 30, 2009
Posts: 217
same here, awesome e.g. fred
appreciated !!!

Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
Have you checked out Aspose?
subject: Question on Multiple inheritance using interfaces.
jQuery in Action, 3rd edition