Interface & Inheritance / subclassing

I’m a bit puzzled.

I thought that if a class implements an interface then it has to implement all methods defined in the interface. However I’m looking at code that does the following:

It has an interface with methods that seem to mimic events:

myInterface

  • MouseUp
  • MouseDown
  • Paint

A class cLevel1 implements the Interface, and has corresponding event definitions. In each interface method it raises the corresponding event.

cLevel2 is a subclass of cLevel1 and inherits the Interface - but it does not implement any of the methods.

So I presume my assumption about interfaces does not extend to inherited interfaces? Because subclasses inherit the methods?

But why not simply use the events? What’s the point of using an interface if all you do is call the corresponding events?

As cLevel2 is a subclass of cLevel1 it already implements the methods. In the parent. The behaviour is inherited.

Yup, that’s what I thought.

But the curious case of the methods just raising the events baffles me. What’s the point?

Because they are Methods they can be overridden in a subclass
You cant do that with events alone