Sail E0 Webinar

MCQs

Total Questions : 30 | Page 2 of 3 pages
Question 11. What is the validity of template parameters?
  1.    inside that block only
  2.    inside the class
  3.    whole program
  4.    any of the mentioned
 Discuss Question
Answer: Option A. -> inside that block only


inside that block only


Question 12. Which of the things does not require instantiation?
  1.    functions
  2.    non virtual member function
  3.    member class
  4.    all of the mentioned
 Discuss Question
Answer: Option D. -> all of the mentioned


The compiler does not generate definitions for functions, non virtual member functions, class or member class because it does not require instantiation.


Question 13. Which parameter is legal for non-type template?
  1.    pointer to member
  2.    object
  3.    class
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> pointer to member


The following are legal for non-type template parameters:integral or enumeration type, Pointer to object or pointer to function, Reference to object or reference to function, Pointer to member.


Question 14. What is meant by template specialization?
  1.    It will have certain data types to be fixed.
  2.    It will make certain data types to be dynamic.
  3.    Certain data types are invalid
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> It will have certain data types to be fixed.


In the template specialization, it will make the template to be specific for some data types.


Question 15. Why we use :: template-template parameter?
  1.    binding
  2.    rebinding
  3.    both a & b
  4.    none of these
 Discuss Question
Answer: Option C. -> both a & b


It is used to adapt a policy into binary ones.


Question 16. Pick out the correct statement.
  1.    you only need to write one function, and it will work with many different
  2.    it will take a long time to execute
  3.    duplicate code is increased
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> you only need to write one function, and it will work with many different


Because of template type parameters, It will work with many types and saves a lot of time.


Question 17. What can be passed by non-type template parameters during compile time?
  1.    int
  2.    float
  3.    constant expression
  4.    none of the mentioned
 Discuss Question
Answer: Option C. -> constant expression


Non-type template parameters provide the ability to pass a constant expression at compile time. The constant expression may also be an address of a function, object or static class member.


Question 18. What is meant by template parameter?
  1.    It can be used to pass a type as argument
  2.    It can be used to evaluate a type.
  3.    It can of no return type
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> It can be used to pass a type as argument


A template parameter is a special kind of parameter that can be used to pass a type as argument.


Question 19. From where does the template class derived?
  1.    regular non-templated C++ class
  2.    templated class
  3.    a or b
  4.    none of the mentioned
 Discuss Question
Answer: Option C. -> a or b


a or b


Question 20. Which keyword can be used in template?
  1.    class
  2.    typename
  3.    both a & b
  4.    function
 Discuss Question
Answer: Option C. -> both a & b


both a & b


Latest Videos

Latest Test Papers