1. | What is encapsulation? |
|
2. | What is the benefit of using encapsulation? |
|
3. | What is an access specifier ? |
|
4. | What is a public access specifier? |
|
5. | What is a private access specifier? |
|
6. | What is a protected access specifier? |
|
7. | What portions of a super class can be used by a subclass? |
|
8. | How are access specifiers used differently in Java and C++? |
|
9. | Can a super class access portions of a subclass? |
|
10. | Why do programmers require that some attributes of a class be accessed only by a member procedure? |
|
Answers
1. | Encapsulation is a technique of linking together attributes and procedures to form an object. |
2. | Encapsulation enables a programmer to institute checks and balances by placing attributes and procedures in a class and then defining rules in the class to control its access. |
3. | An access specifier is a programming language keyword that tells the computer what part of the application can access data and functions/ methods defined within the access specifier. |
4. | The public access specifier determines attributes and procedures that are accessible by using an instance of the class. |
5. | The private access specifier identifies attributes and procedures that are only accessible by a procedure that is defined by the class. |
6. | The protected access specifier stipulates attributes and procedures that can be inherited and used by another class. |
7. | A subclass inherits public and protected portions of the super class. |
8. | In C++, access specifiers define a section of a class that contains attributes and member functions. In Java, each attribute and member method contains the access specifier. |
9. | A super class cannot access any portion of a subclass. |
10. | Programmers require that some attributes of a class be accessed only by a member procedure in order to validate values assigned to attributes. A programmer who wants access to some attributes calls a member procedure, which applies any validation rules before assigning values to attributes. |