Abstraction
Abstraction is an object-oriented programming concept of exposing only the essential features of an object and hiding the implementation details. Users of a class work with what it does, not how it does it.
In languages such as Java, abstraction is achieved with abstract classes and interfaces: they declare the operations a type must support, and concrete classes provide the implementation. This reduces complexity and lets the implementation change without affecting the code that uses it.
package in.ihelpyou;
abstract class Payment {
abstract void pay(double amount); // what, not how
}
class UpiPayment extends Payment {
void pay(double amount) {
System.out.println("Paid " + amount + " via UPI");
}
}
public class Main {
public static void main(String[] args) {
Payment p = new UpiPayment();
p.pay(499.0);
}
}