What is the final class in Java?
If we make any class final, we can’t inherit it into any of the subclasses.
- final class Bike{}
- class Honda1 extends Bike{
- void run(){System.out.println(“running safely with 100kmph”);}
- public static void main(String args[]){
- Honda1 honda= new Honda1();
- honda.run();
- }
- }
Output:Compile Time Error
Recent Posts