Please explain using plain english why we need and why we use Interface in Object Oriented development.
I am in serious confusion.
[+] I’m working on Java. Please provide sample code in Java if any.
Thanks all.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do you mean why do we need interfaces or why do we not using only abstract classes?
Interfaces provide:
1)Abstraction and dependency inversion. High-level classes don’t care about concrete low-level class they work with. More abstration you have, more flexibility you get. For example, you can completely rewrite level that works with DB and you keep untouched other levels of your app because they work with interfaces but not with concrete implementation.
2)In Java interfaces provide multiple inheritance