Java abstract Keyword
The abstract keyword is used to achieve abstrac on in Java. It is a non-access modifier which is used
to create abstract class and method.
The role of an abstract class is to contain abstract methods. However, it may also contain non-
abstract methods. The method which is declared with abstract keyword and doesn't have any
implementa on is known as an abstract method.
Syntax:-
1. abstract class Employee
2. {
3. abstract void work();
4. }
Note - We cannot declare abstract methods in non abstract class.
Rules of abstract keyword
Don'ts
o An abstract keyword cannot be used with variables and constructors.
o If a class is abstract, it cannot be instan ated.
o If a method is abstract, it doesn't contain the body.
o We cannot use the abstract keyword with the final.
o We cannot declare abstract methods as private.
o We cannot declare abstract methods as sta c.
o An abstract method can't be synchronized.