Abstract Method in Java

A method which is declared as abstract and does not have implementation is known as an abstract method. Example of abstract method: abstract void printStatus();. Following is the example of Abstract class that has an abstract method


\begin{lstlisting}
abstract class Bike{
abstract void run();
}
class Honda4 ...
...String args[]){
Bike obj = new Honda4();
obj.run();
}
}
\end{lstlisting}

Output:


\begin{lstlisting}
running safely
\end{lstlisting}

In this example, Bike is an abstract class that contains only one abstract method run. Its implementation is provided by the Honda class.