Early binding refers to the events that occur at compile time Early binding occurs when all information needed to call a function is known at compile time Examples of early binding include normal function calls, overloaded function calls, and overloaded operators The advantage of early binding is efficiency
Correct Answer: Late binding refers to function calls that are not resolved until run time Virtual functions are used to achieve late binding When access is via a base pointer or reference, the virtual function actually called is determined by the type of object pointed to by the pointer
Correct Answer: Dynamic binding (also known as late binding) means that the code associated with a given procedure call is not known until the time of the call at run timeIt is associated with polymorphism and inheritance
Correct Answer: Multiple inheritance is a feature in C++ by which one class can be of different types Say class teaching Assistant is inherited from two classes say teacher and Student
7. What is the difference between realloc() and free()?
Correct Answer: The free subroutine frees a block of memory previously allocated by the malloc subroutine Undefined results occur if the Pointer parameter is not a valid pointer If the Pointer parameter is a null value, no action will occur The realloc subroutine changes the size of the block of memory pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and returns a new pointer to the block The pointer specified by the Pointer parameter must have been created with the malloc, calloc, or realloc subroutines and not been deallocated with the free or realloc subroutines Undefined results occur if the Pointer parameter is not a valid pointer
8. What is the difference between class and structure?
Correct Answer: Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality But C++ extended the structure to contain functions also The major difference is that all declarations inside a structure are by default public Class: Class is a successor of Structure By default all the members inside the class are private
9. What is the output of this program? #include using namespace std; int main() { int arr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout << arr; return 0; }
As we couted to print only arr, it will print the address of the array.
10. What is the output of this program? #include using namespace std; struct sec { int a; char b; }; int main() { struct sec s ={25,50}; struct sec *ps =(struct sec *)&s; cout << ps->a << ps->b; return 0; }