+ 2

I'm confused about interface in Java , can somebody clarify me ???

Interface in java, Why there is no method in interfaces???

26th Dec 2019, 6:14 PM
Saddam Khan Abuzaid
Saddam Khan Abuzaid - avatar
3 odpowiedzi
+ 2
Typically there are some methods in interfaces, but it can be without method bodies Interface Name { type method1; type2 metho2; } method bodies are defined by implementions of interfaces
26th Dec 2019, 6:42 PM
zemiak
+ 2
Interface methods are by default abstract so the class(concrete) implementing it must agree to the contract of providing implementation for all the methods of the interface. Apart from abstract methods interface also has default and static methods which can be declared and defined within the interface itself and it is completely legal. interface A{ void show(); void print(); default void execute(){ //do something } static void terminate(){ //do something } }
27th Dec 2019, 12:46 AM
Avinesh
Avinesh - avatar