Hello,
Interfaces -
An interface is a contract: The person writing the interface says, "hey, I accept things looking that way", and the person using the interface says "OK, the class I write looks that way".
An interface is an empty shell. There are only the signatures of the methods, which implies that the methods do not have a body. The interface can't do anything. It's just a pattern.
For example (pseudo code):
// I say all motor vehicles should look like this:
interface MotorVehicle
{
void run();
int getFuel();
}
// My teammate complies and writes vehicle looking that way
class Car implements MotorVehicle
int fuel;
void run()
print("Wrroooooooom");
int getFuel()
return this.fuel;
Hope this helps.
Regular exam updates, QnA, Predictors, College Applications & E-books now on your Mobile