Learn

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:

  • The public and private keywords 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.
  • The this keyword 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.
  • The this keyword can be used to call methods when writing classes.

Instructions

We’ve given you our full code for our Bank and CheckingAccount classes. Feel free to continue to experiment with the public and private keywords to get a better understanding of what code has access to certain structures.

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?