Skip to main content

Important Introduction to Programming Short Questions

Chapter: 27
Question 1:
What is the purpose of the 'set' functions in a class?
Answer: 'Set' functions assign values to data members and often include validation to ensure that only valid data is stored in the object.
Chapter: 27
Question 2:
What is the purpose of the 'get' functions in a class?
Answer: 'Get' functions retrieve and return the values of data members from an object.
Chapter: 27
Question 3:
Can a destructor return a value or take parameters in C++?
Answer: No, a destructor cannot return a value or take parameters. It is designed solely for cleanup when an object is destroyed.
Chapter: 27
Question 4:
What is a common use case for destructors in C++?
Answer: Destructors are commonly used to deallocate memory or release resources that were acquired during the lifetime of an object.
Chapter: 27
Question 5:
What does the 'dot operator' (.) do in C++ when dealing with class objects?
Answer: The dot operator is used to access the members (functions or variables) of a class object.
Chapter: 27
Question 6:
Why might you use a parameterized constructor instead of a default constructor?
Answer: A parameterized constructor allows you to initialize an object with specific values, giving more control over the object's initial state.
Chapter: 28
Question 7:
What is the main topic discussed in the lecture?
Answer: The lecture focuses on memory allocation in C++ compared to C, especially in the context of classes and objects.
Chapter: 28
Question 8:
How is memory allocation done in C?
Answer: In C, memory allocation is done using functions like malloc(), calloc(), and realloc(), which allocate memory during runtime.
Chapter: 28
Question 9:
What is a structure in C?
Answer: A structure in C is a user-defined data type that can contain multiple data types. It is declared using the struct keyword.
Chapter: 28
Question 10:
How do you declare an object of a structure type?
Answer: An object of a structure type is declared using the syntax struct StructName objectName;.