Why you use the interface for implementing the methods is not it just extra work? |
[Edit] |
Answer
In Java, it will not support a concept like "subclass having morethan one superclass"
ex: class subclass extends superclass1,superclass2
so, to implement this concept , java introduced a new methodalogy called "interface", interface is also a class , but it has only function declarations having no function definitions. therby, we can inherite more than one interfaces through "implements" key word.
For an interface we cont declare an object,but, we have an alternative ,through assignig an object of a class which implements that interface.
ex: interfacename iobj; subclass sobj=new subclass(); iobj=sobj; iobj.funame1(); iobj.funame2(); iobj.funame3(); note: these three funames are the memeber functions of the above interface, and subclass has to give the definition for them, dynamic binding...,right! apart from these already three declared functions , we con't give the reference to the iobj,ok!
the other explanation for implements is , giving definition for a memeber function,today or infuture ,which is declared in past.
At any cost, i missed-out u r Question, plz mail me : thanoojmca@yahoo.com
First answer by Thanooj. Last edit by Thanooj. Contributor trust: 67 [recommend contributor]. Question popularity: 83 [recommend question]
|
Research your answer: |



