-1

In java there is interface which having only abstract method means method declration only and those methods are implement in class that implement interface so why to use interface which has only declaration .This question is asked in interview.

Deepa
  • 1
  • 1
  • The methods declared in an interface aren't *exactly* abstract, though. – Makoto Jan 01 '16 at 09:09
  • Java official documentation provides all the answers to your question http://docs.oracle.com/javase/tutorial/java/concepts/interface.html – awsome Jan 01 '16 at 09:12

1 Answers1

0

Interfaces are used for only declaration of methods because it can achieve multiple behavior. It is the class's responsibility to implement the interfaces and define their methods as they desire.

Interfaces allow same methods to be implemented in different manner by implementing classes, which allows you to achieve behavioral facility.

For understanding sake, you can consider interfaces exist so you can achieve behavioral approach for your application, and class exist to achieve characteristic approach.

Hemang
  • 390
  • 3
  • 20