Skip to content
main-logo
  • +91 637-050-2482
  • santuitreturns@gmail.com
Menu
Menu
  • Home
  • Income Tax
    • Income From Salary
    • Profit or gain from Business/Profession.
    • Capital Gain
    • Income From Other Sources
    • 80C to 80U
    • TDS & TCS
    • ITR FORMS
  • International Taxation
    • Transfer Pricing
    • Non-Resident Taxation
    • Foreign Tax Credit (FTC)
    • Model Tax Convention
    • Base Erosion and Profit Shifting (BEPS)
  • GST
  • Accounting
  • MCQs
    • NEET
    • NEET QUIZ TEST
    • NEET PG MCQ’s
    • NEET PG QUIZ TEST
    • Civil Engineering
    • Mechanical Engineering MCQs
    • CHSL EXAM
      • Logical Reasoning
  • Others
    • Job Tips
  • CA Courses
    • CA Inter/IPCC

10+ TOP C++ MCQs on Template Arguments to Specify Policy Usage

Posted on September 25, 2023

1. What is meant by the template parameter?

A. It can be used to pass a type as an argument
B. It can be used to evaluate a type
C. It can of no return type
D. It can be used to delete a type

View Answer

Answer: A

Explanation: 

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

2. Which keyword can be used in template?

A. class
B. typename
C. both class & typename
D. function

View Answer

Answer: C

Explanation:

 Both keywords can be used as shown below:
template <class T> function declaration;
template <typename T> function declaration;

3. What is the validity of template parameters?

A. inside that block only
B. inside the class
C. whole program
D. inside the main class

View Answer

Answer: A

Explanation:

 Template parameters are valid inside a block only i.e. they have block scope.

4. What will be the output of the following C++ code?

   #include 
   using namespace std;
   template 
   class mysequence 
   {
       T memblock [N];
       public:
       void setmember (int x, T value);
       T getmember (int x);
   };
   template 
   void mysequence :: setmember (int x, T value) 
   {
       memblock[x] = value;
   }
   template 
   T mysequence :: getmember (int x) 
   {
       return memblock[x];
   }
   int main () 
   {  
       mysequence  myints;
       mysequence  myfloats;
       myints.setmember (0, 100);
       myfloats.setmember (3, 3.1416);
       cout << myints.getmember(0) << '\n';
       cout << myfloats.getmember(3) << '\n';
       return 0;
   }


A. 100

B. 3.1416

C.
100
3.1416

D. 4.14

View Answer

Answer: C

Explanation:

 In this program, We are printing the integer in the first function and float in the second function.

5. What will be the output of the following C++ code?

    #include 
    using namespace std;
    template 
    T max (T& a, T& B. 
    {
        return (a>b?a:B.;
    }
  int main () 
    {
        int i = 5, j = 6, k;
        long l = 10, m = 5, n;
        k = max(i, j);
        n = max(l, m);
        cout << k << endl;
        cout << n << endl;
        return 0;
    }

A. 6

B.6
10

C.5
10

D. 5

View Answer

Answer: B

Explanation:

 In this program, We are using the ternary operator on the template function.

6. What will be the output of the following C++ code?

    #include 
    using namespace std;
    template 
    class Test
    {
        public:
        Test()
        {
        };
        ~Test()
        {  
        };
        type Funct1(type Var1)
        {
            return Var1;
        }
        type Funct2(type Var2)
        {
            return Var2;
        }
    };
    int main()
    {
        Test Var1;
        Test Var2;
        cout << Var1.Funct1(200);
        cout << Var2.Funct2(3.123);
        return 0;
    }

A. 100
B. 200
C. 3.123
D. 2003.123

View Answer

Answer: D

Explanation:

 In this program, We are passing the value and returning it from template.

7. What will be the output of the following C++ code?

    #include 
    using namespace std;
    template 
    void loopIt(T x)
    {
        T val[count];
        for(int ii = 0; ii < count; ii++)
        {
            val[ii] = x++;
            cout <<  val[ii] << endl;
        }
    };
  int main()
  {
        float xx = 2.1;
        loopIt(xx);
    }

A. 2.1
B. 3.1

C.2.1
 3.1

 4.1

D. 4.1

View Answer

Answer: C

Explanation:

 In this program, We are using the non-type template parameter to increment the value in the function template.

8. Why we use :: template-template parameter?

A. binding
B. rebinding
C. both binding & rebinding
D. reusing

View Answer

Answer: C

Explanation:

 It is used to adapt a policy into binary ones.

9. Which parameter is legal for non-type template?

A. pointer to member
B. object
C. class
D. baseclass

View Answer

Answer: A

Explanation:

 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.

10. Which of the things does not require instantiation?

A. functions
B. non virtual member function
C. member class
D. all of the mentioned

View Answer

Answer: D

Explanation:

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

    You May Also Like...

  • 10+ TOP C++ MCQs on OOPs Concept – 4
  • 10+ TOP MCQs on C++ vs C
  • 10+ TOP C++ MCQs on Sizes
  • 10+ TOP C++ MCQs on Void
  • 10+ TOP C++ MCQs on Pointer to Void
  • 10+ TOP C++ MCQs on Pointer to Structures
  • 10+ TOP C++ MCQs on Operator Overloading – 1
  • 10+ TOP C++ MCQs on Operator Overloading – 2

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Quick Links

  • Home
  • About Us
  • Privacy Policy
  • Terms of Use
  • Disclaimer
  • Contact Us

Categories

  • Income Tax
  • International Taxation
  • GST
  • MCQs
  • Others
  • CA Courses

Latest Posts

  • Five changes in ITR forms of FY 2024-25 (AY 2025-26)
  • Form 10-IEA: Option to Choose Old Tax Regime
  • What is Section 54EC of the Income Tax Act?
  • What is Section 54F of the Income Tax Act?
©2025 Online Solves. All rights Reserved | Developed by AlgoPage IT Solutions Pvt. Ltd.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT