Encapsulation - Day 3 Flashcards

1
Q

Private usage

A

Private variables are only accessible inside the class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Setter and getter

A

Set values to private variables: setter method
-> mutator methods

Fetch values of private variables: getter method
-> accessor methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Encapsulation definition

A

Restricting access to data.

Basic principle of OOP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Private set up

A

Class Poop {

   Private  ; }

Class Testy {

    Public \_\_\_\_\_\_\_\_{

            Poop poop = new Poop(); 

This Won’t allow access to private variables in class poop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Accessing private variables

A

Getting method

 public  get() {
            Return ;
} 

Setter method

public void set( ) {
this. = variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Getter

A

Returns variable

I.e private void shoes;

public String getShoes() {
Return shoes;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Setter

A

Creates a method to set the data type, variable

private String shoes; (defined in class)

public void setShoes(String shoes) {
this.shoes = shoes;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly