Java Theory
Abstraction:
Abstraction means hiding lower-level details and exposing only the essential and relevant details to the users.
Syntax |
---|
abstract return_type method_name (); |
Example:
Consider an ATM Machine; All are performing operations on the ATM machine like cash withdrawal, money transfer, retrieve mini-statement…etc. But we can't know internal details about the ATM.
Diagram:
Real-Life-Example-of-Abstraction
Example |
---|
public class Main { public static void main(String args[]) { TwoWheeler test = new Honda(); test.run(); } } abstract class TwoWheeler { public abstract void run(); } class Honda extends TwoWheeler { public void run() { System.out.println("Running.."); } } |