Abstraction meaning explained in simple terms with example : Java


* Show functionality hide complexity

*Abstraction implements through abstract class and interface

*If  any class has any abstract method then it can not be instantiated

*Abstract method can not be used in normal class ,but used in abstract class

*Abstract class may have abstract functions.

*Any child class has to override all the abstract class's abstract function othrwise child has to  
  become abstract.

*We never call the abstract function explicitly.automatically runs the code of the abstract

* It is not mandatory that abstract class should have atleast one abstract function

* Cant mark class as abstract and final both ....both have opposite meaning

Example :

abstract class Base
    int x,y;
    void show()
    abstract void  display();

class child extends Base
    void set (int x,int y)
        System.out.println("x "+x);
        System.out.println("y "+y);
    void display()
    public static void main(String args[])
        child c1= new child();

About The Author

Subham Mittal has worked in Oracle for 3 years .
For more java articles ,Click here to Subscribe JavaHungry