MCQsAdvanced MCQsTemplatesTemplates 1).What is the purpose of templates in C++?1) To allow generic programming2) To enable function overloading3) To define custom data types4) None of the above 2).Which of the following can be templated in C++?1) Functions2) Classes3) Structures4) All of the above 3).What does the 'typename' keyword in templates do?1) Defines a type parameter2) Declares a function3) Indicates a template argument4) None of the above 4).What is the syntax for declaring a template for a function?1) template<typename T> return_type function_name()2) template<class T> return_type function_name()3) Both A and B4) None of the above 5).What is the main advantage of using class templates?1) Code reuse for different data types2) Better performance3) Faster execution4) None of the above 6).Can templates be used with non-type parameters?1) Yes2) No3) Only for functions4) Only for classes 7).What happens if no explicit template specialization is provided?1) The compiler generates code for every type2) The code will not compile3) The function is ignored4) None of the above 8).What is the difference between 'template<class T>' and 'template<typename T>'?1) There is no difference2) template<class T> allows more complex types3) template<typename T> is more efficient4) None of the above 9).Which of the following is used to specialize a template?1) template<>2) template<class T> specialization3) template<T> specialization4) None of the above 10).Can template functions be overloaded?1) Yes2) No3) Only for different types4) Only for different return types