Nice work! In this lesson, we dove into some of the more subtle features of classes with a focus on access, encapsulation, and scope. Here are some of the main takeaways from this lesson:
privatekeywords are used to define what parts of code have access to other classes, methods, constructors, and instance variables.
- Encapsulation is a technique used to keep implementation details hidden from other classes. Its aim is to create small bundles of logic.
thiskeyword can be used to designate the difference between instance variables and local variables.
- Local variables can only be used within the scope that they were defined in.
thiskeyword can be used to call methods when writing classes.
We’ve given you our full code for our
CheckingAccount classes. Feel free to continue to experiment with the
private keywords to get a better understanding of what code has access to certain structures.