Java Abstract Class Vs Interface Example Program
Java Abstract Class Vs Interface Example Program
}
Emirates.java (Vendor 2)
@Override
public void eastablishConnectionWithYourTower() {
//connecting using Vodafone way
}
@Override
public void destroyConnectionWithYourTower() {
//destroying connection using Vodafone way
}
}
@Override
public void eastablishConnectionWithYourTower() {
//connecting using Airtel way
}
@Override
public void destroyConnectionWithYourTower() {
//destroying connection using Airtel way
}
}
So to summarize,
For Interface:
Interface is used when you don't know anything about
implementation but know the contract that implementer
should have to accomplish the task.
For Abstract class:
Abstract class is used when you know partial
implementation, where say out of 5 methods, you know
implementation of 3 methods and don't know
implemenatation of 2 methods in that case 2 methods will
be abstract and you need to rely on implementer as a
contract to must provide body of abstract methods to
accomplish the task.