> How does the compiler know that the implementing class can be used where the interface is required
Structural typing.
The instance does not assert to the compiler an exhaustive list of all interfaces it claims to conform to; instead, the compiler determines, during compilation, whether the concrete instance being passed meets the requirements of a declared interface. The net result is that an implementation need not have known about an interface when it was written; it need merely match the interface’s requirements when called upon to do so.
It is, effectively, statically enforced duck typing.
If a class implements all the methods of the interface (as seen at compile-time - same method name, arguments, returns) then that's it, period. Compiler will allow you to use it. Beyond that the interface doesn't "know" about the class and the class doesn't "know" about the interface.
So it doesn't matter the interface didn't even exist when that class was written.
Javascript (without typescript) also has duck typing. The difference with structural typing is that the interface is formalized and enforced compile time.
Is there still something like "Backend extends ProfilePage" in Java?