posted 17 years ago
An object presents a public "interface" to its world. An "interface" adds to that public interface, so it only has methods. [It can have constant fields, but most people think they are a bad idea.]
ExampleNow, to create an Engine class, you can "implement" that interface, whihc means that the ;s are replaced by bodies to their methods.
ExampleI have just put any old stuff in the methods, so you can see what is going on.
Notice you now have a class with methods, three of which are "specified" by the three methods in the interface. Notice that although it doesn't say anything about "public" in the interface, the methods are expected to be implemented as "coderanch."
You can also design a DieselEngine class which also implements Engine.
You can give three names to the type of the PetrolEngine: PetrolEngine, Engine and Object. It is implicity all three at the same time.
Don't wish to blind you with science, but I hope that is of some help.