Encapsulation Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is ENCAPSULATION?

A

Making the atributes (variables) in a class private and providing access to those atributes via public behaviours (methods)

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

What are the ADVANTAGES of ENCAPSULATION?

A
  1. Data Hiding
  2. Increased Flexibility
  3. Reusability
  4. Testing code is easy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is DATA HIDING?

A

The user will have no idea about the inner implementation of the class (implies security)

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

What is INCREASED FLEXIBILITY?

A

We can make the variables of the class as read-only or write-only depending on our requirement

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

What does REUSABILITY mean?

A

Methods can be copied to different/new classes and help meet new requirements

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

How does it allow for EASY TESTING CODE?

A

It is easier to fix larger programs if you know which method is returning the wrong response

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