How Object-Oriented Programming Works

The programs you create with Java can be thought of as objects, just like physical objects that exist in the real world. Objects exist independently of other objects, interact in specific ways, and can often be combined with other objects to form something. Examples of objects in the real world include ham sandwiches, the Nixon tapes, a stereo receiver, and my father-in-law Clint. Examples of objects in a computer include a web browser, the Java compiler, an MP3 file, and a Macromedia Flash plug-in.

If you think of a computer program as a group of objects that interact with each other, you often can come up with a design for the program that's more reliable, easier to understand, and reusable in other projects. ...

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.