as Purge said, this is vJass way of polymorphism.
Basically when you define interface, you just create a set of rules(methods) and when you have function which takes this interface, you know for sure that this function must exist within anything that is passed into the function. From inside you dont know if it is A or B, you just know that it must implement all the methods that are defined inside the interface.
What I said is not completly true, because interface can look like this:
JASS:
interface myI
method run takes nothing returns boolean defaults false
endinterface
Im not 100% sure, only around 99.97% sure that this means that:
if I extend the interface, I may or may not define method run, and if I dont do so, it will always be equal to false, otherwise it will return whatever the method defined inside the struct returns.
Yes class and struct are identical(I call it class cause I use that in C++, but struct is very same in there, and it works very similarily to structs in vJass)
Now I can write:
JASS:
struct A extends myI
method run takes nothing returns boolean
call BJDebugMsg("you have requested A to call .run()")
return true
endmethod
endstruct
struct B extends myI
endstruct
function tester takes myI instance returns boolean
return instance.run()
endfunction
function runner takes nothing returns nothing
local A a = A.create()
local B b = B.create()
local boolean aReturned = tester(a) //will print the message and be true
local booelan bReturned = tester(b) //will be false
endfunction
so now I dont require all structs extending the interface to have the method, but if it doesnt have it, I will just return false