πŸ“Š CPP Programming
Q. Which of the followings is/are automatically added to every class, if we do not write our own?
  • (A) Copy Constructor
  • (B) Assignment Operator
  • (C) A constructor without any parameter
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
πŸ“Š CPP Programming
Q. When a copy constructor may be called?
  • (A) When an object of the class is returned by value.
  • (B) When an object of the class is passed (to a function) by value as an argument.
  • (C) When an object is constructed based on another object of the same class
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
πŸ“Š CPP Programming
Q. Implicit return type of a class constructor is:
  • (A) not of class type itself
  • (B) class type itself
  • (C) a destructor of class type
  • (D) a destructor not of class type
πŸ’¬ Discuss
βœ… Correct Answer: (B) class type itself
πŸ“Š CPP Programming
Q. Which of the following is true about constructors?
1) They cannot be virtual.
2) They cannot be private.
3) They are automatically called by new operator.
  • (A) All 1, 2, and 3
  • (B) Only 1 and 3
  • (C) Only 1 and 2
  • (D) Only 2 and 3
πŸ’¬ Discuss
βœ… Correct Answer: (B) Only 1 and 3
πŸ“Š CPP Programming
Q. Output of following program?
#include<iostream>
using namespace std;
class Point {
Point() { cout << "Constructor called"; }
}; int main()
{
Point t1;
return 0;
}
  • (A) Compiler Error
  • (B) Runtime Error
  • (C) Constructor called
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) Compiler Error
πŸ“Š CPP Programming
Q. #include<iostream>
using namespace std;
class Point {
public:
Point() { cout << "Constructor called"; }
};
int main()
{
Point t1, *t2;
return 0;
}
  • (A) Compiler Error
  • (B) Constructor called Constructor called
  • (C) Constructor called
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (C) Constructor called
πŸ“Š CPP Programming
Q. Which operator is having the highest precedence?
  • (A) postfix
  • (B) unary
  • (C) shift
  • (D) equality
πŸ’¬ Discuss
βœ… Correct Answer: (D) equality
πŸ“Š CPP Programming
Q. Which of the following is FALSE about references in C++?
  • (A) References cannot be NULL
  • (B) A reference must be initialized when declared
  • (C) Once a reference is created, it cannot be later made to reference another object; it cannot be reset.
  • (D) References cannot refer to constant value
πŸ’¬ Discuss
βœ… Correct Answer: (D) References cannot refer to constant value
πŸ“Š CPP Programming
Q. Which of the following functions must use reference?
  • (A) Assignment operator function
  • (B) Copy Constructor
  • (C) Destructor
  • (D) Parameterized constructor
πŸ’¬ Discuss
βœ… Correct Answer: (B) Copy Constructor

Jump to