:doodle { @grid: 10 / 100vmax; } background: @pick(#29B6F6, #FDD835, #5E35B1, #FFCCBC, #E8EAF6, #B2DFDB, #1B5E20, #2979FF); opacity: @r(.9); clip-path: polygon( @rand(50%) 0, 50% @rand(70%), 0 @rand(100%) ); animation: test infinite @r(40s, 70s) linear; @keyframes test { 0% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(@r(-500%, 1000%), @r(-500%, 1000%), 0); } 100% { transform: translate3d(0, 0, 0); } }

Abstraction

Introduction:

A class that is declared with the abstract keyword is known as an abstract class in Java. It can have abstract and non-abstract methods (method with the body). It needs to be extended and its method implemented. It cannot be instantiated. Abstraction is a process of hiding the implementation details and showing only functionality to the user. Another way, it shows only essential things to the user and hides the internal details, for example, sending SMS where you type the text and send the message. You don't know the internal processing about the message delivery. Abstraction lets you focus on what the object does instead of how it does it.

Code

Ways to achieve Abstraction:

  • There are two ways to achieve abstraction in java

  • Abstract class (0 to 100%)

  • Interface (100%)

Points to Remember:

  • An abstract class must be declared with an abstract keyword.

  • It can have abstract and non-abstract methods.

  • It cannot be instantiated.

  • It can have constructors and static methods also.

  • It can have final methods which will force the subclass not to change the body of the method

Example of abstract class:

Code

Abstract Method in Java:

A method that is declared as abstract and does not have implementation is known as an abstract method.

Example of Abstract class that has an abstract method:

Code Code Code

Rule:

  • If there is an abstract method in a class, that class must be abstract.

  • If you are extending an abstract class that has an abstract method, you must either provide the implementation of the method or make this class abstract.

An abstract class having constructor, data member, and methods:

Code