Please give me answer why we use Interface though it contain only blank implementation.

Showing Answers 1 - 8 of 8 Answers

radha

  • Oct 13th, 2005
 

hello frnds, we use interfaces coz ,interfaces r nothing but just ,methods with no body , when we want to implement the interface we can give our own implementation  , some others an give their own implementation , interface is just a blue print.whenever we think that a particular thing can be implemented in diferent ways it can be done by using interfaces.

  Was this answer useful?  Yes

shankar

  • Oct 23rd, 2005
 

first java doesnt support Multiple inheritance so to overcome this we use interfacesInterfaces r like a contract or a flag signal that we use to direct the class which is implementing that interface.once it implement the interface it should override its method.An interface can be empty also.

  Was this answer useful?  Yes

venkatram reddy

  • Oct 25th, 2005
 

With the inheritance we can also achieve the polymorphism concept. And the above answer also holds good.

  Was this answer useful?  Yes

sasikumar

  • Dec 28th, 2005
 

yeah..,nice question.interface has contains only abstract methods(undefined methods).we can write those methods directly in our class.then why they had written into interface means if ur implementing one interface u should ensure that all methods are present in that interface must be in our class.example: if u r implementing animal interface ,assume it has contains two methods walking(),barking().now u shuld override two methods in ur class.(its must ).

  Was this answer useful?  Yes

sekhar

  • Mar 3rd, 2006
 

Thanks sasi kumar.This is very nice answer.

  Was this answer useful?  Yes

bala

  • Apr 26th, 2006
 

When we r implementing the some comman methods in the every class at that time we keep that all methods in the one interface. Another way example:- for example for CD Writer soft ware dovelepment all companies(LG,SAMSUNG) follow the method names r coman.But the internal code is differnet for each company.For write the data or read the data frome cd.Due to it need some understanding between the any OS and the Writers due to we r using different different combinations.. We can say by using the interface concept all r following some comman stadard methods.

The purpose of Marker interface is to just let the compiler know that the clas which implements the Marker Interface will be serialized or cloned. Ther is not any other use of Marker Interface.

E.g If you are travelling by train then you will buy a ticket, So actually ticket has no meaning to you but it will be an instruction to the Ticket checker that you are traveling to some destination. So here you will be the "class" who is implementing "Ticket" interface and instructing to the Ticket checker "class" that I am travelling.

An Interface may Contain implementation or not. Sometimes these type of interfaces (blank interfaces) which are not implemented are called as "marker interfaces".

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions