educative.io

Why don't we use interface instead of abstract class

Hi,

In the “Rate Limiting Using Token Bucket Filter - continued” TokenBucketFilter is defined as an abstract class. Why isn’t it defined as an interface instead?

Hi @Ferenc_Gal
TokenBucketFilter is defined as an abstract class because using abstract class subclasses can implement or override the functionality they want. At the same time, an interface only allows you to define functionality, not implement it.
Happy learning!