0

Every method present inside interface is abstract but in abstract class also we can take only abstract methods then what is the need of interface concept?

kapil
  • 1
  • Not all methods need to be `abstract` in an abstract class. – Kayaman Apr 12 '18 at 09:46
  • Why we took abstract methods in interface – kapil Apr 12 '18 at 09:48
  • I don't know what you're saying, but the duplicate explains everything. – Kayaman Apr 12 '18 at 09:49
  • Every method present inside interface is abstract but in abstract class also we can take only abstract methods then what is the need of interface concept i asking this one – kapil Apr 12 '18 at 09:51
  • Re-read my first comment, then read the duplicate. In fact you can have an abstract class without **any** abstract methods. – Kayaman Apr 12 '18 at 09:51
  • 1
    @Kayaman IMHO this question is not a duplicate. I think the OP wonders why do we need the concept of interface if we can create an abstract class having all its methods abstract. You can find everything in the duplicate but you have to look carefully and it is not obvious as a beginner. – C.Champagne Apr 12 '18 at 09:57
  • @C.Champagne opinion noted. – Kayaman Apr 12 '18 at 10:01
  • can We replace interface concept with abstract class if we replace then what is the use interface. – kapil Apr 12 '18 at 11:56
  • 1
    Should be said in those linked question but the short answer, you can implement more than one interface but only extends one abstract class. – AxelH Apr 12 '18 at 12:13
  • This has got a bit complicated since Java 8. Interface methods don't have to be abstract. You can have default methods and static methods in interfaces. – DodgyCodeException Apr 12 '18 at 12:30

0 Answers0