Topic:   What is the final method?
Apr 01, 2021 13:05 1 Replies 19 Views SANJAY

What is the final method?

Prev Next
Topic Replies (1)
  1. 1
    idnkx user

    RANJIT

    If we change any method to a final method, we can't override it. More Details.
    1. class Bike{
    2. final void run(){System.out.println("running");}
    3. }
    4.
    5. class Honda extends Bike{
    6. void run(){System.out.println("running safely with 100kmph");}
    7.
    8. public static void main(String args[]){
    9. Honda honda= new Honda();
    10. honda.run();
    11. }
    12. }
    13. Output:Compile Time Error

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect