+ 1
In factory design how we are able to create object of an interface
2 Answers
+ 2
You can't instantiate an interface. You can instantiate a class that implements an interface though. You can also refer to an object that implements that interface by the interface in a polymorphic way.
MyInterface obj = new MyInterface();
is not valid.
class A implements MyInterface {}
A obj = new A();
is valid
as is:
MyInterface obj = new A();
This doesn't instantiate an interface, but uses the interface to refer to an instantiated object in a polymorphic way.
0
I am not sure but interface cannot be instatiated..