adplus-dvertising

Welcome to the Derived Classes,Templates and Exception Handling in C++ MCQs Page

Dive deep into the fascinating world of Derived Classes,Templates and Exception Handling in C++ with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Derived Classes,Templates and Exception Handling in C++, a crucial aspect of Object Oriented Programming Using C++. In this section, you will encounter a diverse range of MCQs that cover various aspects of Derived Classes,Templates and Exception Handling in C++, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Object Oriented Programming Using C++.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Derived Classes,Templates and Exception Handling in C++. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Object Oriented Programming Using C++.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Derived Classes,Templates and Exception Handling in C++. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Derived Classes,Templates and Exception Handling in C++ MCQs | Page 6 of 24

Explore more Topics under Object Oriented Programming Using C++

Q51.
What is the output of this program?
    #include <iostream>
    using namespace std;
    template<typename type>
    type Max(type Var1, type Var2)
    {
        return Var1 > Var2 ? Var1:Var2;
    }
    int main()
    {
        int p;
        p = Max(100, 200);
        cout << p << endl;
        return 0;
    }
Discuss
Answer: (b).200
Q52.
What is the output of this program?
    #include <iostream>
    using namespace std;
    template<typename type> 
    class Test
    {
        public:
        Test()
        {
        };
        ~Test()
        {
        };
        type Funct1(type Var1)
        {
            return Var1;
        }
        type Funct2(type Var2)
        {
            return Var2;
        }
    };
    int main()
    {
        Test<int> Var1;
        Test<float> Var2;
        cout << Var1.Funct1(200) << endl;
        cout << Var2.Funct2(3.123) << endl;
        return 0;
    }
Discuss
Answer: (c).200
Q53.
What is the output of this program?
    #include <iostream>
    using namespace std;
    template<typename type>
    class TestVirt
    {
        public:
        virtual type TestFunct(type Var1)
        {
            return Var1 * 2;
        }
    };
    int main()
    {
        TestVirt<int> Var1;
        cout << Var1.TestFunct(100) << endl;
        return 0;
    }
Discuss
Answer: (b).200
Q54.
What is the output of this program?
    #include <iostream>
    using namespace std;
    template<typename T> 
    inline T square(T x)
    {
        T result;
        result = x * x;
        return result;
    };
    int main()
    {
        int i, ii;
        float x, xx;
        double y, yy;
        i = 2;
        x = 2.2;
        y = 2.2;
        ii = square(i);
        cout << i << " "  << ii << endl;
        yy = square(y);
        cout << y << " " << yy << endl;
    }
Discuss
Answer: (b).2 4
Q55.
What is the output of this program?
    #include <iostream>
    using namespace std;
    template<typename T> 
    void loopIt(T x)
    {
        int count = 3;
        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);
    }
Discuss
Answer: (d).2.1
Q56.
What can be passed by non-type template parameters during compile time?
Discuss
Answer: (c).constant expression
Discuss
Answer: (c).regular non-templated C++ class or templated class
Discuss
Answer: (a).It can be used to pass a type as argument
Q59.
Which keyword can be used in template?
Discuss
Answer: (c).both class & typename
Q60.
What is the validity of template parameters?
Discuss
Answer: (a).inside that block only

Suggested Topics

Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!