0
Interface in java
plz explain
2 odpowiedzi
+ 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).
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.