0

I have a doubt, if at all the inherited interface members are not implemented then the derived results is an abstract class?

If so can I create an instance of that interface given that the underlying derived class is an abstract?

HaveNoDisplayName
  • 7,711
  • 106
  • 32
  • 44

2 Answers2

1

Q: extend interfaces but leaving them unimplemented, is that an abstract class?

A: If you want to compile a class that that leaves interfaces unimplemented then that class has to be an abstract class, otherwise you will get a compiler error.

Q: Can I create an instance of that interface ...

A: stop right there - you cannot create instances of interfaces. You can also not create instances of abstract classes. That class has to be 'concrete' before you can instantiate it.

Please review these other SO Questions:

Community
  • 1
  • 1
YoYo
  • 7,796
  • 8
  • 50
  • 67
0

For a concrete class all members of an interface must be defined, with abstract classes you can mark the members as abstract and let a concrete class that derives from it, define the methods.

Instances can only be created from concrete classes, however you can access these instance objects using a interface or abstract class reference.

Interface a = new InterfaceImplementation();
a.SomeInterfaceMethod();

Against this is typical across languages, but will vary depending on the language in question, I.e. Some languages are single paradigm, such as purely functional.

BhavO
  • 2,281
  • 1
  • 9
  • 12