logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming References See What Others Are Saying!
  • Question
  • Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    struct Tab
    {
        short n;
    };
    int main()
    {
        Tab b;
        Tab& rb = b;
        b.n = 5;
        cout << b.n << " " << rb.n << " ";
        rb.n = 8;
        cout << b.n << " " << rb.n;
        return 0; 
    }


  • Options
  • A. It will result in a compile time error.
  • B. The program will print the output 5 5 5 8.
  • C. The program will print the output 5 5 8 8.
  • D. The program will print the output 5 5 5 5.

  • Correct Answer
  • The program will print the output 5 5 8 8. 


  • More questions

    • 1. Which of the following operator is overloaded for object cout?

    • Options
    • A. >>
    • B. <<
    • C. +
    • D. =
    • Discuss
    • 2. Which of the following concepts means determining at runtime what method to invoke?

    • Options
    • A. Data hiding
    • B. Dynamic Typing
    • C. Dynamic binding
    • D. Dynamic loading
    • Discuss
    • 3. Which of the following statement is correct?

    • Options
    • A. A reference is stored on heap.
    • B. A reference is stored on stack.
    • C. A reference is stored in a queue.
    • D. A reference is stored in a binary tree.
    • Discuss
    • 4. For automatic objects, constructors and destructors are called each time the objects

    • Options
    • A. enter and leave scope
    • B. inherit parent class
    • C. are constructed
    • D. are destroyed
    • Discuss
    • 5. What will be the output of the following program?
      #include <iostream.h> 
      enum xyz 
      {
          a, b, c
      }; 
      int main()
      {
          int x = a, y = b, z = c; 
          int &p = x, &q = y, &r = z; 
          p = z; 
          p = ++q;
          q = ++p;
          z = ++q + p++; 
          cout<< p << " " << q << " " << z;
          return 0; 
      }

    • Options
    • A. 2 3 6
    • B. 4 4 7
    • C. 4 5 8
    • D. 3 4 6
    • Discuss
    • 6. Which of the following statement is correct?

    • Options
    • A. A constructor is called at the time of declaration of an object.
    • B. A constructor is called at the time of use of an object.
    • C. A constructor is called at the time of declaration of a class.
    • D. A constructor is called at the time of use of a class.
    • Discuss
    • 7. Which of the following statement is correct about the program given below?
      #include<iostream.h>
      #include<process.h> 
      class CuriousTab
      {
          static int x; 
          public:
          CuriousTab()
          {
              if(x == 1)
                  exit(0); 
              else
                  x++;
          }
          void Display()
          {
              cout<< x << " ";
          }
      };
      int CuriousTab::x = 0; 
      int main()
      {
          CuriousTab objCuriousTab1; 
          objCuriousTab1.Display(); 
          CuriousTab objCuriousTab2; 
          objCuriousTab2.Display(); 
          return 0; 
      }

    • Options
    • A. The program will print the output 1 2.
    • B. The program will print the output 0 1.
    • C. The program will print the output 1 1.
    • D. The program will print the output 1.
    • E. The program will report compile time error.
    • Discuss
    • 8. What will be the output of the following program?
      #include<iostream.h> 
      class India
      {
          public:
          struct CuriousTab
          {
              int   x;
              float y;
              void Function(void)
              {
                  y = x = (x = 4*4); 
                  y = --y * y;
              }
              void Display()
              {
                  cout<< y << endl;
              } 
          }B; 
      }I; 
      int main()
      {
          I.B.Display(); 
          return 0;
      }

    • Options
    • A. 0
    • B. 1
    • C. -1
    • D. Garbage value
    • Discuss
    • 9. Which of the following statements is correct?

      1. Once the variable and the reference are linked they are tied together.
      2. Once the reference of a variable is declared another reference of that variable is not allowed.

    • Options
    • A. Only 1 is correct.
    • B. Only 2 is correct.
    • C. Both 1 and 2 are correct.
    • D. Both 1 and 2 are incorrect.
    • Discuss
    • 10. Which of the following header file includes definition of cin and cout?

    • Options
    • A. istream.h
    • B. ostream.h
    • C. iomanip.h
    • D. iostream.h
    • Discuss


    Comments

    There are no comments.

Enter a new Comment