The final keyword in java is used to restrict the user. The java final keyword can be used in many context.
Final can be:
variable
method
class
If you make any method as final, you cannot override it.
class Bike{ final void run(){System.out.println("running");} } class Honda extends Bike{ void run(){System.out.println("running safely with 100kmph");} public static void main(String args[]){ Honda honda= new Honda(); honda.run(); } }
Output:Compile Time Error
Liked By
Write Answer
What is final method in java?
Join MindStick Community
You have need login or register for voting of answers or question.
Anonymous User
01-Apr-2015The final keyword in java is used to restrict the user. The java final keyword can be used in many context.
Final can be:
If you make any method as final, you cannot override it.