Templates and Generic Programming – MCQs

30 Score: 0 Attempted: 0/30 Subscribe
1. : What is the primary purpose of templates in C++?





2. : Which keyword is used to define a function template in C++?





3. : What is required to define a class template?





4. : What is a benefit of using templates?





5. : How many types of templates are mainly supported in C++?





6. : Which of the following is not a type of template?





7. : What does template instantiation mean?





8. : Which template parameter allows a class to work with any type?





9. : Templates allow functions to work with:





10. : What does the term “generic programming” imply?





11. : What happens if a template function is called with a type that lacks required operators?





12. : Can a template function be overloaded in C++?





13. : Which of the following is not true about templates?





14. : Can templates be used with user-defined data types?





15. : What does a compiler do when it sees a template function?





16. : What is a constraint of using templates?





17. : What is the default behavior of the compiler regarding templates?





18. : In a class template, what is the syntax to specify the data type?





19. : When is the actual code for a template function generated?





20. : Can class templates have multiple parameters?





21. : Which of the following is a valid template declaration?

23. : Which of the following is false about function templates?





24. : Why might a developer use a class template?





25. : Can templates be recursive?





26. : What is the major advantage of templates over function overloading?





27. : What does type inference mean in the context of templates?





28. : Are templates part of C++ Standard Library?





29. : What happens if a template is used incorrectly?





30. : Can templates be combined with inheritance?





Leave a Comment

All copyrights Reserved by MCQsAnswers.com - Powered By T4Tutorials