MCQ Bank
What is the sequence of event(s) when deallocating memory of an object using delete operator?
- A) Only block of memory is deallocated for object
- B) Memory is deallocated first before calling destructor
- C) Only destructor is called for object
- D) Destructor is called first before deallocating memory
What will be the output of the following code segment?
int n=8;
cout<<oct<<n;
- A) 11
- B) 1000
- C) 8
- D) 10
_______ operators are the ones that require only one operand to work.
- A) Binary
- B) Unit
- C) Single
- D) Unary
If operator function is non-member function then object on left side of operator cannot be_________?
- A) Built-in data type
- B) Object of different class
- C) Object of operator class
- D) Object of member function
Overloaded delete operator function takes parameter of void pointer and returns.
- A) void (nothing)
- B) object pointer
- C) void pointer
- D) int pointer
_____________ must be included to use stream manipulator in your code.
- A) conio.h
- B) iostream
- C) stdlib.h
- D) iomanip
*this is a pointer that always points to
- A) Current pointer of the class
- B) A Value of data member
- C) Current function of the class
- D) Current object of the class
The concept of ________________ allows us to separate the interface from the implementation of the class.
- A) encapsulation
- B) polymorphism
- C) inheritance
- D) pointers
In overloading the assignment (=) operator, which object(s) will call the operator function?
- A) Left object of the assignment operator
- B) No object will call the operator function
- C) Right object of the assignment operator
- D) Both objects will call the operator function
When an operator function is defined as member function for a binary Plus (+) operator then the number of extra arguments it takes is/are.
- A) Two
- B) N arguments
- C) One
- D) Zero
The endl and flush are _______
- A) Operators
- B) Manipulators
- C) Objects
- D) Functions
Friend function declaration can go ___________________ the class
- A) in the member function of
- B) only outside
- C) anywhere in
- D) only within
Functions declared with the _________________ specifier in a class member list are called
friend functions of that class.
- A) private
- B) public
- C) friend
- D) protected
In overloading the assignment (=) operator, which object will be passed as an argument(s) in the operator function?
- A) Both objects will be passed
- B) Left object of the assignment operator
- C) Right object of the assignment operator
- D) No objects will be passed
Which one of the following is the correct statement about operator overloading?
- A) N-arithmetic operators can be overloaded only.
- B) Precedence of operators are changed after overloading.
- C) Arithmetic operators can be overloaded only.
- D) Associativity and precedence of operators do not change.
When an operator function is defined as member function for a Unary operator then the number of extra arguments it takes is/are,
- A) N arguments
- B) One
- C) Zero
- D) Two
Memory allocated from heap or free store _____________________.
- A) can be allocated to classes only
- B) cannot be returned back unless freed explicitly using malloc and realloc
- C) cannot be returned back unless freed explicitly using free and delete operators
- D) can be returned back to the system automatically
Ternary operator is shown as _________.
- A) &&
- B) |||
- C) ?:
- D) ===
A friend function of a class is a function defined ________________________.
- A) outside that class and that has the right to access protected members of the class only.
- B) outside that class and that has the right to access all members of the class.
- C) outside that class and that has the right to access public members of the class only
- D) inside that class and that has no access to the members of the class
Friend classes are used in cases where one class is ____________to another class
- A) independent
- B) loosely coupled
- C) encapsulated
- D) tightly coupled