Workshop: Creating an Object

To see a working example of classes and inheritance, you will create classes that represent two types of objects: cable modems, which will be implemented as the CableModem class, and DSL modems, which will be implemented as the DslModem class.

For the sake of simplicity, the workshop will focus on a few simple attributes and behavior for these objects:

  • Each object should have a speed and be able to display it when asked.

  • Each object should be able to connect to the Internet.

One thing that cable modems and DSL modems have in common is that they both have a speed. Because it is something they share, it could be put into a class that is the superclass of both the CableModem and DslModem classes. Call this class Modem ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH 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.