- interface MyInterfaceExe {
- public void MyInterfaceExe (){
- // code here
- }
- }
No ! we cannot have a constructor in an interface. Compiler will give an error.
- interface MyInterfaceExe {
- public static void MyInterfaceExe (){
- // code here
- };
- }
----------------------------------------------------
- interface MyInterfaceExe {
- public default void MyInterfaceExe (){
- // code here
- };
- }
In above case, Yes ! we can have a constructor only if we have either static or default keyword in constructor bodies ending with (;) semicolon.
No comments:
Post a Comment