CS304 Quiz 4 Solved Spring 2023 | Final Term Preparation
2 Different Solved Quiz
Quiz 1:
Question #1:
Which of the following can be passed as type arguments to templates?
a) Primitive types
b) None of the given options
c) User-defined types
d) Both Primitive types and User-defined types
Correct Answer: d) Both Primitive types and User-defined types
Question #2:
We can change the behavior of a template using __________.
a) Function Templates
b) None of the given options
c) Class Templates
d) Template Parameters
Correct Answer: d) Template Parameters
Question #3:
When we specialize a function template, it is called _____________________.
a) Function template overriding
b) Function template overloading
c) Function overloading
d) Function overriding
Correct Answer: b) Function template overloading
Question #4:
A template argument is preceded by the keyword ________.
a) template
b) class
c) type*
d) vector
Correct Answer: a) template
Question #5:
Which of the following represents partial specialization?
a) template< class T, type T>
b) template< typename T, class W >
c) template< int , char >
d) template< class T, class U, int >
Correct Answer: b) template< typename T, class W >
Question #6:
In C++ generic programming is done using_________
a) Procedures
b) Packages
c) None of the given options
d) Templates
Correct Answer: d) Templates
Question #7:
The parameters given in the template definition other than those used for mentioning templates types are called ____________.
a) None of the given options
b) Non-Type Parameters
c) Default Type Parameters
d) Type Parameters
Correct Answer: b) Non-Type Parameters
Question #8:
Which of the following is the correct syntax for passing two type arguments to a template?
a) template< typename T, typename U >
b) template Typename< T, U >
c) template< type T, type U >
d) template< type T, U >
Correct Answer: a) template< typename T, typename U >
Question #9:
Which of the following is the correct code to instantiate the object of the given template Vector class for int type?
template <class T>
class Vector{};
a) Vector obj<>int;
b) Vector obj <int>;
c) Vector <int> obj;
d) Vector int obj;
Correct Answer: c) Vector <int> obj;
Question #10:
Which of the following is the correct way to define a template class X?
a) class< typename T > class X { };
b) template< typename T > class X { };
c) typename <class T > class X { };
d) template class X { };
Correct Answer: b) template< typename T > class X { };
To get Social Media Services Visit Our Website
Askmunir Click Here
Quiz 2:
Question #1:
We can change the behavior of a template using __________.
a) Function Templates
b) None of the given options
c) Class Templates
d) Template Parameters
Correct Answer: d) Template Parameters
Question #2:
Which of the following may inherit from an ordinary class?
a) All of the given options
b) Partial specialization
c) Complete specialization
d) Class template
Correct Answer: a) All of the given options
Question #3:
A template argument is preceded by the keyword ________.
a) class
b) template
c) vector
d) type*
Correct Answer: b) template
Question #4:
In statement "template <class T, class U, int I = 5>", the non-type parameter is _____________.
a) All of the given options
b) class U
c) int I
d) class T
Correct Answer: c) int I
Question #5:
A class template ____________.
a) Does not support generic methods
b) Does not support static members
c) Facilitates reuse of class
d) Does not facilitate reuse of class
Correct Answer: c) Facilitates reuse of class
Question #6:
In resolution order, highest priority is given to __________________ in template specialization.
a) partial specialization
b) complete specialization
c) general template
d) none of the given options
Correct Answer: a) partial specialization
Question #7:
Which will be the Primary task or tasks of generic programming?
a) Build concrete models of the concepts
b) Categorize the abstractions in a domain into concepts
c) Implement generic algorithms based on the concepts
d) All of given
Correct Answer: d) All of given
Question #8:
In resolution order of function templates, the compiler searches for _____________ in the end.
a) generic template
b) complete specialization
c) partial specialization
d) ordinary function
Correct Answer: d) ordinary function
Question #9:
In order to define a class template, the first line of the definition must be:
a) Template Class <ClassName>
b) Class <Template T>
c) typename <template T>
d) template <typename T>
Correct Answer: d) template <typename T>
Question #10:
When we specialize a function template, it is called _____________________.
a) function template overriding
b) function template overloading
c) function overloading
d) function overriding
Correct Answer: b) function template overloading