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> 
    int main()
    {
        int x = 0;
        int &y = x; y = 5; 
        while(x <= 5)
        {
            cout<< y++ << " ";
            x++;
        }
        cout<< x; 
        return 0; 
    }


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

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


  • More questions

    • 1. How many instances of an abstract class can be created?

    • Options
    • A. 1
    • B. 5
    • C. 13
    • D. 0
    • Discuss
    • 2. Which of the following keywords is used to control access to a class member?

    • Options
    • A. Default
    • B. Break
    • C. Protected
    • D. Asm
    • Discuss
    • 3. Which of the following also known as an instance of a class?

    • Options
    • A. Friend Functions
    • B. Object
    • C. Member Functions
    • D. Member Variables
    • Discuss
    • 4. Which of the following factors supports the statement that reusability is a desirable feature of a language?

    • Options
    • A. It decreases the testing time.
    • B. It lowers the maintenance cost.
    • C. It reduces the compilation time.
    • D. Both A and B.
    • Discuss
    • 5. How many times a constructor is called in the life-time of an object?

    • Options
    • A. Only once
    • B. Twice
    • C. Thrice
    • D. Depends on the way of creation of object
    • Discuss
    • 6. What will be the output of the following program?
      #include<iostream.h> 
      int main()
      {
          float Amount;
          float Calculate(float P = 5.0, int N = 2, float R = 2.0);
          Amount = Calculate(); 
          cout<< Amount << endl; 
          return 0;
      }
      
      float Calculate(float P, int N, float R)
      {
          int Year = 1;
          float Sum = 1 ;
          Sum = Sum * (1 + P * ++N * R);
          Year =  (int)(Year + Sum);
          return Year; 
      }

    • Options
    • A. 21
    • B. 22
    • C. 31
    • D. 32
    • E. None of these
    • Discuss
    • 7. Which of the following is an abstract data type?

    • Options
    • A. int
    • B. double
    • C. string
    • D. Class
    • Discuss
    • 8. Can a class have virtual destructor?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 9. Which of the following statement is correct?

    • Options
    • A. A referenced has to be de-referenced to access a value.
    • B. A referenced does not need to be de-referenced to access a value.
    • C. A referenced has to be double de-referenced to access a value.
    • D. Whether a reference should be de-referenced or not depends on the type of the reference.
    • Discuss
    • 10. Which of the following cannot be declared as virtual?

    • Options
    • A. Constructor
    • B. Destructor
    • C. Data Members
    • D. Both A and C
    • Discuss


    Comments

    There are no comments.

Enter a new Comment