Java abstract Keyword
The abstract keyword is used to achieve abstraction 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 implementation is known as an abstract method.
Note - We cannot declare abstract methods in non abstract class.
Rules of abstract keyword
Examples of abstract Keyword
Example 1: Abstract class containing the abstract methodTest it Now
Bike is running
Example 2: Abstract class containing the abstract and non-abstract methodTest it Now
Bike is running Car is running
Example 3: Abstract class containing the constructorTest it Now
Constructor is invoked
Example 4: Abstract class containing overloaded abstract methodsTest it Now
abstract method is invoked overloaded abstract method is invoked
Example 5: Inner abstract classTest it Now
inner abstract class is invoked
Example 6: Nested abstract classTest it Now
nested abstract class is invoked