What is the final class in Java?

If we make any class final, we can’t inherit it into any of the subclasses.

  1. final class Bike{}
  2. class Honda1 extends Bike{
  3.   void run(){System.out.println(“running safely with 100kmph”);}
  4.   public static void main(String args[]){
  5.   Honda1 honda= new Honda1();
  6.   honda.run();
  7.   }
  8. }
Output:Compile Time Error