O'Reilly logo

Java Garage by Eben Hewitt

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

Inheritance

The following example shows how to create a subclass using the extends keyword. In this example, Vehicle is the superclass, and Car is the subclass that inherits all of Vehicle's behavior. Car then will define behavior specific only to Cars.

class Vehicle {}
class Car extends Vehicle {}

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