logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming Constructors and Destructors See What Others Are Saying!
  • Question
  • 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

  • Correct Answer
  • enter and leave scope 


  • More questions

    • 1. What will be the output of the following program?
      #include<iostream.h> 
      typedef void(*FunPtr)(int);
      int Look(int = 10, int = 20);
      void Note(int); 
      int main()
      {
          FunPtr ptr = Note;
          (*ptr)(30); 
          return 0;
      }
      int Look(int x, int y)
      {
          return(x + y % 20);
      }
      void Note(int x)
      {
          cout<< Look(x) << endl;
      }

    • Options
    • A. 10
    • B. 20
    • C. 30
    • D. 40
    • E. Compilation fails.
    • Discuss
    • 2. Which of the following statement is correct about the program given below?
      #include<iostream.h>
      void Tester(float xx, float yy = 5.0);
      class CuriousTab
      {
          float x; 
          float y; 
          public:
          void Tester(float xx, float yy = 5.0)
          {
              x = xx;
              y = yy;
              cout<< ++x % --y; 
          }
      };
      int main()
      {
          CuriousTab objCuriousTab;
          objCuriousTab.Tester(5.0, 5.0);
          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
    • 3. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      long FactFinder(long = 5); 
      int main()
      {
          for(int i = 0; i<= 0; i++)
              cout<< FactFinder() << endl; 
          return 0;
      }
      long FactFinder(long x)
      {
          if(x < 2)
              return 1; 
          long fact = 1; 
          for(long i = 1; i <= x-1; i++)
              fact = fact * i; 
          return fact; 
      }

    • Options
    • A. The program will print the output 1.
    • B. The program will print the output 24.
    • C. The program will print the output 120.
    • D. The program will print the output garbage value.
    • E. The program will report compile time error.
    • Discuss
    • 4. How many types of polymorphisms are supported by C++?

    • Options
    • A. 1
    • B. 2
    • C. 3
    • D. 4
    • Discuss
    • 5. What will be the output of the following program?
      #include<iostream.h> 
      class CuriousTabTest
      {
          public:
          CuriousTabTest(int &x, int &y)
          {
              x++;
              y++;
          } 
      };
      int main()
      {
          int a = 10, b = 20;
          CuriousTabTest objBT(a, b); 
          cout<< a << " " << b; 
          return 0; 
      }

    • Options
    • A. 10 20
    • B. 11 21
    • C. Garbage Garbage
    • D. It will result in a compile time error.
    • Discuss
    • 6. Which of the following statement is correct?

    • Options
    • A. The order of the default argument will be right to left.
    • B. The order of the default argument will be left to right.
    • C. The order of the default argument will be alternate.
    • D. The order of the default argument will be random.
    • Discuss
    • 7. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTab
      {
          int *p; 
          public:
          CuriousTab(int xx, char ch)
          {
              p  = new int(); 
              *p = xx + int(ch); 
              cout<< *p;
          }
          ~CuriousTab() 
          {
              delete p;
          }
      };
      int main()
      {
          CuriousTab objCuriousTab(10, 'B'); 
          return 0;
      }

    • Options
    • A. The program will print the output 76.
    • B. The program will print the output 108.
    • C. The program will print the output garbage value.
    • D. The program will report compile time error.
    • Discuss
    • 8. What will be the output of the following program?
      #include<iostream.h> 
      struct MyData
      {
          public:
          int Addition(int a, int b = 10)
          {
              return (a *= b + 2);
          }
          float Addition(int a, float b);
      };
      int main()
      {
          MyData data;
          cout<<data.Addition(1)<<" ";
          cout<<data.Addition(3, 4);
          return 0; 
      }

    • Options
    • A. 12 12
    • B. 12 18
    • C. 3 14
    • D. 18 12
    • E. Compilation fails.
    • Discuss
    • 9. Which of the following statement is correct regarding destructor of base class?

    • Options
    • A. Destructor of base class should always be static.
    • B. Destructor of base class should always be virtual.
    • C. Destructor of base class should not be virtual.
    • D. Destructor of base class should always be private.
    • Discuss
    • 10. What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?

    • Options
    • A. Compile-time error.
    • B. Preprocessing error.
    • C. Runtime error.
    • D. Runtime exception.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment