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> 
    class Number
    {
        int Num; 
        public:
        Number(int x = 0)
        {
            Num = x;
        }
        void Display(void)
        {
            cout<< Num;
        }
        void Modify(); 
    };
    void Number::Modify()
    {
        int Dec;
        Dec = Num % 13; 
        Num = Num / 13; 
        
             if(Num  > 0 ) Modify()   ; 
             if(Dec == 10) cout<< "A" ; 
        else if(Dec == 11) cout<< "B" ; 
        else if(Dec == 12) cout<< "C" ; 
        else if(Dec == 13) cout<< "D" ;
        else               cout<< Dec ;
    }
    int main()
    {
        Number objNum(130);
        objNum.Modify();
        return 0; 
    }


  • Options
  • A. 130
  • B. A0
  • C. B0
  • D. 90

  • Correct Answer
  • A0 


  • More questions

    • 1. Which of the following constructor is used in the program given below?
      #include<iostream.h> 
      class CuriousTab
      {
          int x, y; 
          public:
          CuriousTab(int xx = 10, int yy = 20 )
          {
              x = xx; 
              y = yy;
          }
          void Display()
          {
              cout<< x << " " << y << endl;
          } 
          ~CuriousTab()
          { } 
      };
      int main()
      {
          CuriousTab objCuriousTab; 
          objCuriousTab.Display(); 
          return 0;
      }

    • Options
    • A. Copy constructor
    • B. Simple constructor
    • C. Non-parameterized constructor
    • D. Default constructor
    • Discuss
    • 2. What will be the output of the following program?
      #include<iostream.h> 
      class CuriousTabBase
      {
          public:
              float x; 
      }; 
      class CuriousTabDerived : public CuriousTabBase
      {
          public: 
              char ch; 
              void Process()
              {
                  ch = (int)((x=12.0)/3.0);
              }
              void Display()
              {
                  cout<< (int)ch;
              } 
      }; 
      int main()
      {
          class CuriousTabDerived  *objDev = new CuriousTabDerived;
          objDev->Process();
          objDev->Display();
          return 0; 
      }

    • Options
    • A. The program will print the output 4.
    • B. The program will print the ASCII value of 4.
    • C. The program will print the output 0.
    • D. The program will print the output garbage.
    • Discuss
    • 3. Which of the following statement is correct?

    • Options
    • A. C++ allows static type checking.
    • B. C++ allows dynamic type checking.
    • C. C++ allows static member function be of type const.
    • D. Both A and B.
    • Discuss
    • 4. How many default constructors per class are possible?

    • Options
    • A. Only one
    • B. Two
    • C. Three
    • D. Unlimited
    • Discuss
    • 5. Which of the following function declaration is/are incorrect?

    • Options
    • A. int Sum(int a, int b = 2, int c = 3);
    • B. int Sum(int a = 5, int b);
    • C. int Sum(int a = 0, int b, int c = 3);
    • D. Both B and C are incorrect.
    • E. All are correct.
    • Discuss
    • 6. Which of the following statements is correct in C++?

    • Options
    • A. Classes cannot have data as protected members.
    • B. Structures can have functions as members.
    • C. Class members are public by default.
    • D. Structure members are private by default.
    • Discuss
    • 7. Which of the following is the correct way of declaring a function as constant?

    • Options
    • A. const int ShowData(void) { /* statements */ }
    • B. int const ShowData(void) { /* statements */ }
    • C. int ShowData(void) const { /* statements */ }
    • D. Both A and B
    • Discuss
    • 8. Which of the following statement is correct?

    • Options
    • A. An array of references is acceptable.
    • B. Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.
    • C. An array of references is not acceptable.
    • D. Reference is like a structure.
    • Discuss
    • 9. Which of the following concepts provides facility of using object of one class inside another class?

    • Options
    • A. Encapsulation
    • B. Abstraction
    • C. Composition
    • D. Inheritance
    • Discuss
    • 10. Which of the following concepts means wrapping up of data and functions together?

    • Options
    • A. Abstraction
    • B. Encapsulation
    • C. Inheritance
    • D. Polymorphism
    • Discuss


    Comments

    There are no comments.

Enter a new Comment