The PrintLine class prints each line. The anonymous class can reference variable and methods in the containing class. In places where you might normally need function pointers, use an abstract method in a base class or interface as a prototype and implement appropriate methods in derived classes. Multiple Inheritance Without true multiple inheritance, Java forces some difficult design choices. A Java class may inherit from only one base class.
Any additional inheritance is through implementation of interfaces.
When a class is has more than one distinct parent, you must select one parent to be the single base class. The other parents must be interfaces. This is not an easy choice. In larger projects, there are usually several situations where classes require multiple inheritance. Often, this involves the major classes in the application, producing difficult design decisions that you need to make early in the process.