Which of the following supports the concept that re-usability is a desirable feature of a language ?
It reduces the testing time
It reduces maintenance cost
It decreases the compilation time
It reduced both testing and maintenance time
Answer: Option D
As we will be using the existing code therefore we don’t need to check the code again and again so testing and maintenance time decreases but the compiler time may increase or remains same because though we are reusing the code but every part needs to be compiled and extra include statement needs to be executed therefore compilation time may remain same or increases.
What is the correct syntax of declaring array of pointers of integers of size 10 in C++ ?
int arr = new int;
int **arr = new int*;
int *arr = new int;
int *arr = new int*;
Answer: Option B
As we have to declare an array of pointers of integers therefore we need double pointer array in which each element is collection pointers to integers. Therefore the correct syntax is int **arr = new int*;
What happens if a pointer is deleted twice in a program as shown in the following C++ statements ?
int *ptr =new int; delete ptr; delete ptr;
The program runs perfectly
Answer: Option A
Deleting a pointer twice in a program may lead to run-time error or may run perfectly. It depends on the compiler how it handles the situation so the program may compile and run successfully but actually the program should give a run-time error(segmentation fault) as you are trying to access the unauthorized memory of the system.