A derived class can inherit non-private data members, properties, and methods from a super class. The definition of non-private means an access mode of PROTECTED or PUBLIC. If you are using packages the definition of non-private is extended to include PACKAGE-PROTECTED or PACKAGE-PRIVATE if the derived class and super class are in the same package. A super class itself can have a super class. In this way, a derived class can have a chain of super classes forming a class hierarchy, in which each super class inherits from the super class above it. Each derived class inherits the non-private class members from all super classes in its class hierarchy.

To define a top-level super class, you simply define it as a class. To define a class that inherits from another class, you use the INHERITS keyword.

Here is the syntax for defining a class that inherits from another class:

class <derived-class-name> inherits <super-class-name>:

In a derived class that inherits from another class, you can define a method to override a method in its class hierarchy. For example, you may want to define specialized behavior for a method in a derived class. The derived method must have the same or less restrictive visibility as the overridden super class method. For example, you can override a PROTECTED super class method with a PUBLIC or a PROTECTED derived class method. The derived class method should also have the same method name, return type, and number of parameters. Each corresponding parameter must be of the same mode (input, output, or input-output) and of the same data type as the method it overrides.

Note: To a derived class you can also add additional methods that are not defined in the super class.

To indicate that a method overrides the super class method, you use the override key word. Here is the syntax for overriding a super class method:

method [acces-mode] override <return-type> <method-name>( ):
Note: If you use PACKAGE-PRIVATE or PACKAGE-PROTECTED access modes those restrictions apply. For more information see, Access modes.