Creating an Object
To see a working example of classes and inheritance, in the next project you create classes that represent two types of objects: cable modems, which are implemented as the CableModem
class, and DSL modems, which are implemented as the DslModem
class. The workshop focuses on simple attributes and behavior for these objects:
• Each object should have a speed that it can display.
• 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 this is something they share, it can be put into a class that is the superclass of both the CableModem
and DslModem
classes. Call this class Modem
. In NetBeans, create a new empty Java class called ...
Get Sams Teach Yourself Java™ in 24 Hours, Sixth 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.