let say there are two interfaces like the following
interface int1{ int meth1(); }
interface int22{ int meth1(); }
ok then
i am implementing both of them in a calss as follows
class mycl implements int1,int2 {}
now as the rule says, if a class implements an interface it must complete its signature. now my questions is that if i define meth1(), as that method is in both interface, may i know how can i define both of that methods. please answer me
Total Answers and Comments: 13
Last Update: August 12, 2007 Asked by: Y Niranjan Prasad
RE: let say there are two interfaces like the followin...
yes,
you are correct, there is no way to define the method twice. and it doesnt matter which method we define because we want the method with that name and the compiler dont bother about in which interface it comes from, it checks only that the method is defined or not. am i correct?
RE: let say there are two interfaces like the followin...
Question: let say there are two interfaces like the followinginterface int1{int meth1();}interface int22{int meth1();}ok theni am implementing both of them in a calss as followsclass mycl implements int1,int2{}now as the rule says, if a class implements an interface it must complete its signature.now my questions is that if i define meth1(), as that method is in both interface, may i know how can i define both of that methods.please answer me
RE: let say there are two interfaces like the followin...
Hi , I dont see any benefit in doing like this and its not a good design too :( I would recommend to change your design something like this.interface int1{ //Eg. Place some methods which will be exposed to the third partyint meth1();}interface int22 extends int1{// Some other methods (but not meth1) which will be used for the internal activities.int meth2();}then implement your class like thisclass mycl implements int22{ // Implement both meth1 and meth2 here.}