logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming Functions See What Others Are Saying!
  • Question
  • What will be the output of the following program?
    #include<iostream.h> 
    void MyFunction(int a, int b = 40)
    {
        cout<< " a = "<< a << " b = " << b << endl;
    }
    int main()
    {
        MyFunction(20, 30);
        return 0; 
    }


  • Options
  • A. a = 20 b = 40
  • B. a = 20 b = 30
  • C. a = 20 b = Garbage
  • D. a = Garbage b = 40

  • Correct Answer
  • a = 20 b = 30 


  • More questions

    • 1. 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
    • 2. Which of the following statement is correct?

    • Options
    • A. A reference is a constant pointer.
    • B. A reference is not a constant pointer.
    • C. An array of references is acceptable.
    • D. It is possible to create a reference to a reference.
    • Discuss
    • 3. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTabArray
      {
          int array[3][3];
          public:
          CuriousTabArray(int arr[3][3] = NULL)
          { 
              if(arr != NULL)
              for(int i = 0; i < 3; i++) 
                  for(int j = 0; j < 3; j++) 
                      array[i][j] = i+j; 
          } 
          void Display(void)
          {
              for(int i = 0; i < 3; i++) 
                  for(int j = 0; j < 3; j++)
                      cout<< array[i][j] << " "; 
          }
      };
      int main()
      {
          CuriousTabArray objBA;
          objBA.Display();
          return 0; 
      }

    • Options
    • A. The program will report error on compilation.
    • B. The program will display 9 garbage values.
    • C. The program will display NULL 9 times.
    • D. The program will display 0 1 2 1 2 3 2 3 4.
    • Discuss
    • 4. Which of the following cannot be used with the keyword virtual?

    • Options
    • A. class
    • B. member functions
    • C. constructor
    • D. destructor
    • Discuss
    • 5. Which of the following statement is correct about the program given below?
      #include<iostream.h>
      void Tester(int xx, int yy = 5);
      class CuriousTab
      {
          int x; 
          int y; 
          public:
          void Tester(int xx, int yy = 5)
          {
              x = xx;
              y = yy;
              cout<< ++x % --y; 
          }
      };
      int main()
      {
          CuriousTab objCuriousTab;
          objCuriousTab.Tester(5, 5);
          return 0; 
      }

    • Options
    • A. The program will print the output 0.
    • B. The program will print the output 1.
    • C. The program will print the output 2.
    • D. The program will print the output garbage value.
    • E. The program will report compile time error.
    • Discuss
    • 6. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTab
      {
          public:
          CuriousTab()
          {
              cout<< "Curious";
          }
          ~CuriousTab()
          {
              cout<< "Tab";
          }
      };
      int main()
      {
          CuriousTab objTab;
          return 0; 
      }

    • Options
    • A. The program will print the output Curious.
    • B. The program will print the output Tab.
    • C. The program will print the output CuriousTab.
    • D. The program will report compile time error.
    • Discuss
    • 7. Destructor calls are made in which order of the corresponding constructor calls?

    • Options
    • A. Reverse order
    • B. Forward order
    • C. Depends on how the object is constructed
    • D. Depends on how many objects are constructed
    • Discuss
    • 8. Which of the following type of data member can be shared by all instances of its class?

    • Options
    • A. Public
    • B. Inherited
    • C. Static
    • D. Friend
    • Discuss
    • 9. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      int main()
      {
          int m = 2, n = 6;
          int &x = m++;
          int &y = n++;
          m = x++; 
          x = m++;
          n = y++;
          y = n++;
          cout<< m << " " << n; 
          return 0; 
      }

    • Options
    • A. The program will print output 3 7.
    • B. The program will print output 4 8.
    • C. The program will print output 5 9.
    • D. The program will print output 6 10.
    • E. It will result in a compile time error.
    • Discuss
    • 10. Which of the following statement is incorrect?

    • Options
    • A. Default arguments can be provided for pointers to functions.
    • B. A function can have all its arguments as default.
    • C. Default argument cannot be provided for pointers to functions.
    • D. A default argument cannot be redefined in later declaration.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment