Kathryn introduces encapsulation as a way to make your programs more secure by preventing unauthorized classes and objects from accessing certain variables and methods.
- [Instructor] One of the fundamental concepts…in object-oriented programming is encapsulation.…Encapsulation is the process of wrapping…data and methods into a single unit, in our case a class.…In other words, encapsulation is a way…to make your programs more secure…by preventing unauthorized classes and objects…from accessing certain variables and methods.…Now why would you want some objects…not to access certain variables?…Think of your bank account.…You aren't allowed to withdraw money from your account…unless you have money.…
You can't deposit a negative amount,…and you shouldn't have direct access to change your balance.…Let's take a look at this type of example in code.…Here we have a bank account class.…We have two private properties:…account number and account balance.…Then we have a constructor where we give it…the account number and account balance…and set those properties appropriately…and then print out the fact we've created an account.…Next on line 12 we have a method called deposit,…and this allows us to deposit money in our account.…
- Downloading Java 9 and choosing an IDE
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Working with inheritance and interfaces
- Learning lambda
Skill Level Beginner
1. Getting Started
2. Java Basics
3. Control Flow
4. Beyond the Basics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.