Data Structures Demystified (Demystified)
1. | What is a user -defined data type? | |
2. | How do you determine the size of a structure? | |
3. | Why would you use a structure? | |
4. | Why happens when you declare an instance of a structure? | |
5. | How do you access parts of a structure? | |
6. | What is a pointer? | |
7. | Why would you use a pointer in a program? | |
8. | What is a pointer to a pointer? | |
9. | Why would you use a pointer to a pointer in a program? | |
10. | What is shown on the screen if you display the content of a pointer variable? | |
Answers
1. | A user-defined data type is a group of primitive data types defined by the programmer. |
2. | The size of a structure is the sum of the sizes of all the primitive data types within the structure. |
3. | You use a structure to group together related data. |
4. | When you declare an instance of a structure, memory is reserved for all the primitive data types defined within the structure. |
5. | You access parts of a structure by referring to the name of the instance of the structure followed by the dot operator, which is then followed by a primitive data type that is defined within the structure. |
6. | A pointer is a variable and can be used as an element of a structure and as an attribute of a class in some programming languages such as C++, but not Java. However, the contents of a pointer is a memory address of another location of memory, which is usually the memory address of another variable, element of a structure, or attribute of a class. |
7. | You use a pointer in a program in order to reduce the number of times data is copied within memory. |
8. | A pointer to a pointer is a variable whose value is an address of another pointer variable. |
9. | You use a pointer to a pointer in a program in order to arrange data without having to move data in memory. |
10. | The address is shown on the screen if you display the content of a pointer variable. |
Категории