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 Conversion Operators

Posted on September 24, 2023

1. What is the return type of the conversion operator?

A. void
B. int
C. float
D. no return type

View Answer

Answer: D

Explanation: 

 Conversion operator doesn’t have any return type not even void.

2. Why we use the “dynamic_cast” type conversion?

A. result of the type conversion is a valid
B. to be used in low memory
C. result of the type conversion is an invalid
D. it is used for storage

View Answer

Answer: A

Explanation:

 It is used to check that operators and operands are compatible after conversion.

3. How many parameters does a conversion operator may take?

A. 0
B. 1
C. 2
D. as many as possible

View Answer

Answer: A

Explanation:

 0 parameters does a conversion operator will take.

4. What will be the output of the following C++ code?
    #include 
    using namespace std;
    class sample1 
    {
        float i, j;
    };
    class sample2 
    {
        int x, y;
        public:
        sample2 (int a, int B. 
        {
             x = a; 
             y = b;
        }
        int result() 
        { 
             return x + y;
         }
    };
    int main () 
    {
        sample1 d;
        sample2 * padd;
        padd = (sample2*) &d;
        cout<< padd->result();
        return 0;
    }

A. 20
B. runtime error
C. random number
D. runtime error or random number

View Answer

Answer: D

Explanation:

 As it assigns to a reference to an object of another incompatible type using explicit type-casting.

5. What will be the output of the following C++ code?
    #include 
    using namespace std;
    class sample
    {
        public:
        sample(int i) : m_i(i) { }
        public:
        int operator()(int i = 0) const 
        { 
            return m_i + i; 
        }
        operator int () const   
        { 
            return m_i; 
        }
        private:
        int m_i;
        friend int g(const sample&);
    };
    int f(char C.
    {
        return c;
    }
    int main()
    {
        sample f(2);
        cout << f(2);
        return 0;
    }

A. 3
B. 4
C. 5
D. 6

View Answer

Answer: B

Explanation:

 In this program, we are adding its value with it itself, So only we got the output as 4.

6. What will be the output of the following C++ code?
    #include 
    #include 
    using namespace std;
    class Complex
    {
        private:
        double real;
        double imag;
        public:
        Complex(double r = 0.0, double i = 0.0) : real(r), imag(i)
        {}
        double mag()
        {  
            return getMag();
        }
        operator double ()
        {
            return getMag();
        }
        private:
        double getMag()
        {
            return sqrt(real * real + imag * imag);
        }
    };
    int main()
    {
        Complex com(3.0, 4.0);
        cout << com.mag();
        cout << com;
        return 0
    }

A. 5 5
B. 4 5
C. 6 6
D. 7 5

View Answer

Answer: A

Explanation:

 In this program, we are calculating the magnitude value by two ways.

7. What will be the output of the following C++ code?
    #include 
    #include 
    using namespace std;
    class test
    {
        public:
        operator string () 
        {  
            return "Converted";
        }
    };
    int main()
    {
        test t;
        string s = t;
        cout << s << endl;
        return 0;
    }

A. converted
B. error
C. run time error
D. convertedconverted

View Answer

Answer: A

Explanation:

 In this program, We casted the string to the object of the class.

8. What will be the output of the following C++ code?
    #include 
    using namespace std;
    int main()
    {
        double a = 21.09399;
        float b = 10.20;
        int c ;
        c = (int) a;
        cout << c ;
        c = (int) b;
        cout << c ;
        return 0;
    }

A. 2110
B. 1210
C. 21
D. 121

View Answer

Answer: A

Explanation:

 In this program, we casted the data type to integer.

9. How are types therein user-defined conversion?

A. 1
B. 2
C. 3
D. 4

View Answer

Answer: B

Explanation:

 There are two types of user-defined conversions. They are conversion by the constructor, Conversion functions.

10. Pick out the correct syntax of operator conversion.

A. operator float()const
B. operator float()
C. operator const
D. operator const()

View Answer

Answer: A

Explanation:

 The syntax of operator conversion is operator float()const.

    You May Also Like...

  • 10+ TOP MCQs on C++ Basic Concepts
  • 10+ TOP C++ MCQs on OOPs Concept – 1
  • 10+ TOP C++ MCQs on OOPs Concept – 2
  • 10+ TOP MCQs on C++ Types
  • 10+ TOP C++ MCQs on Booleans
  • 10+ TOP C++ MCQs on Character Types
  • 10+ TOP C++ MCQs on Pointers into Arrays
  • 10+ TOP C++ MCQs on Constants

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