Java program to show use of final…


This program tells that the function which is once declared as final cannot be overridden. Here function mesh() is declared as final so it cannot be overridden.

class Base
{
   final void mesh()
   {
      System.out.println(“This is superclass function”);
   }
}

class Override extends Base
{
/*

  void mesh()            //Function mesh can not be Overridable
  {
    System.out.println(“This is Override function”);
  }  

*/
}

class OverrideDemo
{
  public static void main(String args [])
  {
    Override ob=new Override();
    ob.mesh();
  }
}

Add Comment