- interface MyInterfaceExe {
- MyInterfaceExe exe = new MyInterfaceExe();
- }
No ! we cannot instantiate an interface. Compiler will give an error saying that cannot instantiate the type of MyInterfaceExe.
- interface MyInterfaceExe {
- MyInterfaceExe exe = new MyInterfaceExe(){ };
- }
Yes ! we can create the object of an interface using anonymous class as above.
No comments:
Post a Comment