Summary

You have now covered two of the four cornerstones of object-oriented programming: abstraction and encapsulation. This section summarizes what we've seen.

OOP is all about special support for class types and the operations on them. Objects are variables whose type is a class. Classes, objects, and methods belong together in a unbreakable way. The methods in a class can only be invoked on objects that belong to that class. If you don't have an object, you cannot invoke one of the object methods. You cannot write a method in class A that is invoked on an object of some unrelated class B. There is no way to get that past the compiler in Java.

There are no structures or records in Java. The most important way to group related things is ...

Get Just Java™ 2 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.