Home Javatutorials Java final method
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java final method

Advertisement
Here we have given the use of final keyword with method. An example is also provided for better understanding.

final keyword when used with method results in final method, which cannot be overridden in subclass. final keyword is used to restrict user.

final keyword is also used with class and variable.

final method can be declared as:

public final String convertCurrency()

Example:

public class FinalDemo 
{
public final void display()
{
System.out.println("In class FinalDemo");
}
}
class A extends FinalDemo
{
public void display() // Error Final method cannot be overridden
{
System.out.println("hi");
}
}

Resource:

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 9, 2013

Ask Questions?    Discuss: Java final method  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com