Chapter    4

Discovering Inheritance, Polymorphism, and Interfaces

An object-based language is a language that encapsulates state and behaviors in objects. Java’s support for encapsulation (discussed in Chapter 3) qualifies it as an object-based language. However, Java is also an object-oriented language because it supports inheritance and polymorphism (as well as encapsulation). (Object-oriented languages are a subset of object-based languages.) In Chapter 4 I introduce you to Java’s language features that support inheritance and polymorphism. Also, I introduce you to interfaces, Java’s ultimate abstract type mechanism.

Building Class Hierarchies

We tend to categorize stuff by saying things like “cars are vehicles” or “savings accounts are ...

Get Learn Java for Android Development, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.