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
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
The 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.