Encapsulation - Day 3 Flashcards
Private usage
Private variables are only accessible inside the class
Setter and getter
Set values to private variables: setter method
-> mutator methods
Fetch values of private variables: getter method
-> accessor methods
Encapsulation definition
Restricting access to data.
Basic principle of OOP
Private set up
Class Poop {
Private ; }
Class Testy {
Public \_\_\_\_\_\_\_\_{ Poop poop = new Poop();
This Won’t allow access to private variables in class poop
Accessing private variables
Getting method
public get() { Return ; }
Setter method
public void set( ) {
this. = variable
Getter
Returns variable
I.e private void shoes;
public String getShoes() {
Return shoes;
}
Setter
Creates a method to set the data type, variable
private String shoes; (defined in class)
public void setShoes(String shoes) {
this.shoes = shoes;
}