Home > C++ Programming > Quizzes > C++ Programming Practice Test 2
C++ Programming Practice Test 2
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 80% Most missed: “Predict the output of following C++ program. | #include using namespace std; cla…”
C++ Programming Practice Test 2
Time left 00:00
25 Questions

1. Default values for a function are specified when ____.
2. What is the built in library function to compare two strings?
3. Which of the following operators should be preferred to overload as a global function rather than a member method?
4. Which one of the following is correct, when a class grants friend status to another class?
5. Predict the output?
#include using namespace std; class Test
{ int x;
Test()
{ x = 5;
} }; int main()
{
Test *t = new Test; cout << t->x;
}
6. Which of the following best defines the syntax for template function?
7. class Test { int x;
}; int main() {
Test t; cout << t.x; return 0;
}
8. Assigning one or more function body to the same name is called ____________.
9. Which function is used to position back from the end of file object?
10. What does the sequence adaptor provide?
11. Which of the following is true about this pointer?
12. When one object reference variable is assigned to another object reference variable then
13. Which of the following operator functions cannot be global?
14. What happens when delete is used for a NULL pointer? int *ptr = NULL; delete ptr;
15. For automatic objects, constructors and destructors are called each time the objects
16. The value 132.54 can be represented using which data type?
17. Which among the following is a mandatory condition for downcasting?
18. Which of the following is not correct (in C++)?
1. Class templates and function templates are instantiated in the same way
2. Class templates differ from function templates in the way they are initiated
3. Class template is initiated by defining an object using the template argument
4. Class templates are generally used for storage classes
19. Which of the following functions must use reference?
20. What kind of error can arise when there is a problem with memory?
21. Which of the following in Object Oriented Programming is supported by Function overloading and default arguments features of C++?
22. Which is the pointer which denotes the object calling the member function?
23. Output of following program?
#include using namespace std; int fun(int=0, int = 0); int main()
{ cout << fun(5); return 0;
} int fun(int x, int y)
{ return (x+y);
}
24. Which of the following are member dereferencing operators in CPP? 1. * 2. :: 3. ->* 4. ::* 5. ->
25. Which among the following is/are type(s) of this pointer?