final Modifier

Declares that a class cannot be extended or that a method or property cannot be overridden.

final statement


  • statement
    Required. A class, method, or property definition.


The final modifier is used to specify that a class cannot be extended or that a method or property cannot be overridden. This prevents other classes from changing the behavior of the class by overriding important functions. Methods with the final modifier can be hidden or overloaded by methods in derived classes.

Methods and properties in classes and classes can be marked with the final modifier. Interfaces, fields, and members of interfaces cannot take the final modifier.

You may not combine the final modifier with the other inheritance modifier (abstract). By default, class members are neither abstract nor final. The inheritance modifiers cannot be combined with the static modifier.


The following example illustrates a use of the final modifier. The final modifier prevents the base-class method from being overridden by methods from the derived class.

class CBase {
   final function methodA() { print("Final methodA of CBase.") };
   function methodB() { print("Non-final methodB of CBase.") };

class CDerived extends CBase {
   function methodA() { print("methodA of CDerived.") };
   function methodB() { print("methodB of CDerived.") };

var baseInstance : CBase = new CDerived;

The output of this program show that the final method is not overridden:

Final methodA of CBase.
methodB of CDerived.


Version .NET

See Also


abstract Modifier

hide Modifier

override Modifier

var Statement

function Statement

class Statement


Scope of Variables and Constants

Type Annotation

Other Resources