DEV Community

Saravanan B
Saravanan B

Posted on

Core Java - Abstraction

Abstraction
Abstract means theoretical not practical or not implemented.
If we need to watch TV we need not to know how TV works we just switch channels using remote.

Abstract class can be fully and partially implemented Abstract class.

Abstraction means hiding the internal details of implementation.

We cannot create a instance of abstract class

public abstract class BMV {
    void commonFunctionality() {
        System.out.println("Inside common fun");
    }
    abstract void acclerate();
}
Enter fullscreen mode Exit fullscreen mode
public class ThreeSeries extends BMV {
    @Override
    void acclerate() {
        System.out.println("Inside 3 series can go upto 120");
    }
}
Enter fullscreen mode Exit fullscreen mode
public abstract class FiveSeries extends BMV{
    abstract void acclerate();
}
Enter fullscreen mode Exit fullscreen mode
public class Test {
    public static void main(String[] args) {
        ThreeSeries three = new ThreeSeries();
        three.acclerate();
        three.commonFunctionality();
    }
}
Enter fullscreen mode Exit fullscreen mode

Output - Inside 3 series can go upto 120
Inside common fun

Access modifiers --

we can't mark abstract class as final.
we can't mark abstract method as static.

Top comments (0)