Interface in java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Interface in java

plz explain

31st Mar 2017, 10:38 AM
Harin Rajan K.R
Harin Rajan K.R - avatar
2 Answers
+ 6
Interface is a user defined datatype developed to avoid ambiguity error of multiple inheritance. Interface contains all method as public, static and final. Interface can be implemented to class for their use because they cannot be instantiated (cannot create objects of interface).
31st Mar 2017, 10:48 AM
Sachin Artani
Sachin Artani - avatar
0
Interfaces are used to declare methods. It's like inheritance, it's used to keep method names consistent in similar classes and reduce code repetition. Let's say you want a particular code to run every time the method is called. Instead of writing code for every class that uses the method, you can call super and add any additional code which runs specifically for that class.
31st Mar 2017, 10:45 AM
Hassie
Hassie - avatar