O'Reilly logo

Modern Compiler Implementation in Java, Second Edition by Jens Palsberg, Andrew W. Appel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

14Object-Oriented Languages

ob-ject: to feel distaste for something

Webster’s Dictionary

An important characteristic of object-oriented languages is the notion of extension or inheritance. If some program context (such as the formal parameter of a function or method) expects an object that supports methods m1, m2, m3, then it will also accept an object that supports m1, m2, m3, m4.

14.1 CLASS EXTENSION

Program 14.1 illustrates the use of class extension in Java. Every Vehicle is an Object; every Car is a Vehicle; thus every Car is also an Object. Every Vehicle (and thus every Car and Truck) has an integer position field and a move method.

In addition, a Car has an integer passengers field and an await method. The variables in scope on entry to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required