What Objects Are

As stated, objects are created by using a class of objects as a guideline. The following is an example of a class:

public class Modem {
}

Any object created from this class can't do anything because it doesn't have any attributes or behavior yet. You need to add those or this class that won't be terribly useful. You could expand the class into the following:

public class Modem {
    int speed;
    public void displaySpeed() {
        System.out.println("Speed: " + speed);
    }
}

The Modem class now should be recognizable to you because it looks a lot like the programs you have written during Hours 1 through 9. The Modem class begins with a class statement, as your programs have, except that it has a public statement alongside it. The public ...

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.