logo

CuriousTab

CuriousTab

Functions problems


  • 1. Which of the following statement is correct?

  • Options
  • A. Constructors can have default parameters.
  • B. Constructors cannot have default parameters.
  • C. Constructors cannot have more than one default parameter.
  • D. Constructors can have at most five default parameters.
  • Discuss
  • 2. Which of the following statement is correct?

  • Options
  • A. C++ enables to define functions that take constants as an argument.
  • B. We cannot change the argument of the function that that are declared as constant.
  • C. Both A and B.
  • D. We cannot use the constant while defining the function.
  • Discuss
  • 3. Which of the following statement is incorrect?

  • Options
  • A. The default value for an argument can be a global constant.
  • B. The default arguments are given in the function prototype.
  • C. Compiler uses the prototype information to build a call, not the function definition.
  • D. The default arguments are given in the function prototype and should be repeated in the function definition.
  • Discuss
  • 4. Which of the following statement is correct?

  • Options
  • A. Overloaded functions can have at most one default argument.
  • B. An overloaded function cannot have default argument.
  • C. All arguments of an overloaded function can be default.
  • D. A function if overloaded more than once cannot have default argument.
  • Discuss
  • 5. Where the default value of parameter have to be specified?

  • Options
  • A. Function call
  • B. Function definition
  • C. Function prototype
  • D. Both B or C
  • Discuss
  • 6. Which of the following function prototype is perfectly acceptable?

  • Options
  • A. int Function(int Tmp = Show());
  • B. float Function(int Tmp = Show(int, float));
  • C. Both A and B.
  • D. float = Show(int, float) Function(Tmp);
  • Discuss
  • 7. Which of the following function / types of function cannot have default parameters?

  • Options
  • A. Member function of class
  • B. main()
  • C. Member function of structure
  • D. Both B and C
  • Discuss
  • 8. Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    static int Result;
    class India
    {
        public:
        void Change(int x = 10, int y = 20, int z = 30)
        {
            cout<< x + y + z;
        }
        void Display(int x = 40, float y = 50.00)
        {
            Result = x % x; 
            cout<< Result;
        }
    };
    class CuriousTab
    {
        int x, y; 
        public:
        void Change(int x, int y = 50)
        {
            cout<< x + y;
        }
    };
    class CuriousTab: public India, public CuriousTab
    {
        public:
        void Display(int x = 10, int xx = 100, int xxx = 1000)
        {
            Result = x + xx % x * x;
            cout<< Result ; 
        }
    };
    int main()
    {
        CuriousTab objCuriousTab;
        objCuriousTab.India::Display(10, 20.00);
        return 0; 
    }

  • Options
  • A. The program will print the output 0.
  • B. The program will print the output 10.
  • C. The program will print the output 30.
  • D. The program will print the output 40.
  • E. The program will report compile time error.
  • Discuss
  • 9. What will be the output of the following program?
    #include<iostream.h> 
    class CuriousTabSample
    {
        public:
            int   a; 
            float b;
            void CuriousTabFunction(int a, float b, float c = 100.0f)
            {
                cout<< a % 20 + c * --b;
            } 
    }; 
    int main()
    {   CuriousTabSample objCuriousTab;
        objCuriousTab.CuriousTabFunction(20, 2.000000f, 5.0f);
        return 0; 
    }

  • Options
  • A. 0
  • B. 5
  • C. 100
  • D. -5
  • E. None of these
  • Discuss
  • 10. What will be the output of the following program?
    #include<iostream.h> 
    class CuriousTab
    {
        public: 
        int x, y;
        CuriousTab(int xx = 10, int yy = 20)
        {
            x = xx;
            y = yy; 
        }
        void Exchange(int *, int *);
    };
    int main()
    {
        CuriousTab objA(30, 40); 
        CuriousTab objB(50); 
        objA.Exchange(&objA.x, &objB.y); 
        cout<< objA.x << " " << objB.y << endl; 
        return 0;
    }
    void CuriousTab::Exchange(int *x, int *y)
    {
        int t;
        t  = *x;
        *x = *y;
        *y = t ; 
    }

  • Options
  • A. 20 10
  • B. 30 20
  • C. 20 30
  • D. 30 40
  • E. 50 30
  • Discuss

First 2 3 4 5 6 7