Using inheritance and polymorphism in Java
In your code, two classes differently extend a base class ClassificationRule. 
Objects of these classes are added to a list, cast as the base class. 
They are retrieved from the list and a method, apply(), which is present in the base class but overridden in the child classes.
As you intend, the apply() method as present in the child class will run, not the apply() method from the base class. 

In the case of your code, the child class does not actually gain functionality from the base class. You are inheriting solely in order manipulate objects of different types as if they were of one homogenous type, because you know they provide certain functionality.

In software engineering terms, you would say 'the classes implement an interface'. 
An interface looks very much like an empty base class, like the one you wrote, and it is a Java language feature different from a base class. Implementing an interface (i.e. providing some agreed functionality) is different from inheriting functionality. 

And the code for it is different, you would write public interface ClassificationRule {, and public class RuleFirstOccrnc implements ClassificationRule {.

In Java, you can only inherit from one class (thought that class may itself have a parent). But you can implement as many interfaces as you like. A typical java object will implement interfaces that let it be sorted (comparable), serialized to transmissable data (serializable), etc, but can only ever inherit from a single base class. 
C++ lets you inherit multiple base classes. Things go horribly wrong when you do. Or at least when I do.