Link to home
Start Free TrialLog in
Avatar of muvend
muvend

asked on

java interface

In java we cannot extend more than one class i get that part, I also know that we extend classes to borrow functionality.

But I don't get the point of implementing an interface, to me interfaces don't give you anything (because the methods in them are empty), they only force you to implement every method in them so what is the point of implementing an interface class if it doesn't give us anything in return.
SOLUTION
Avatar of ioanton
ioanton

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of muvend
muvend

ASKER

Thanks for all your replies but I still don't get it. I have done a degree in networking so I know all about standards, for example an RJ45 is defined on the physical layer of the OSI model so a chinese manufacturer knows how to make an RJ45 network cable just by following the RJ45 docs defined in the physical layer of the OSI model..etc...

Runnable interface class has run() method, the Thread class implements Runnable interface so all Threads must have run() in them. I want to know where the run() method gets it is functionality from, is it something which is hardcoded into the JVM? Because looking at the source code of the Runnable interface it doesn't have anything in it yet the run() method is as power as the main() method in that it is a system thread which has its fare share of cpu time.

package java.lang;

public interface Runnable {
       public abstract void run();
}
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> Thanks for all your replies but I still don't get it
Did you read the article I referred to?
It concludes:
As you can probably imagine by now, interfaces provide a cleaner way of implementing cross cutting functionality in classes than inheritance.