Skip to content

Tezritu/encapsulation-

Repository files navigation

encapsulation-

Using this With Methods

Nice work! In this lesson, we dove into some of the more subtle features of Preview: Docs Loading link description 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, Preview: Docs Loading link description methods , Preview: Docs Constructors are like normal methods within the class, but are used to initialize the object of the class. constructors , and instance Preview: Docs Loading link description 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 In the code editor, we’ve provided the full code for Bank.java and CheckingAccount.java.

Run the code and try to experiment with the private and public keywords.

Here are some ideas that you can experiment with:

Create a method to close an account. Method to apply fees or charges. Introduce different currencies into the code. Concept Review

About

Using this With Methods

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages