MCQ Bank
For the joining of two strings in string class, we may use “+” operator, can we use “-” operator the same way for subtracting strings?
- A) Yes
- B) No
- C) Yes along “+” operator only
- D) Yes along “:?” operator only
If class A is a friend of class B, and class B is a friend of class C. If class A wants class C to be a friend, __________________
- A) it has to declare , class A as a friend
- B) it has to declare, class C as a friend
- C) it has to declare, class B as a friend
- D) it has to declare, class B and class A as friend classes
Which of the following is a destination of cout stream?
- A) Constant
- B) Data type
- C) Variable
- D) Printer
Which statement is true about the following code in C++? int &j = i;
- A) The value of variable i is assigned to the variable j
- B) The address of variable i is assigned to the variable j
- C) j is a synonym of variable i
- D) The address of variable j is assigned to the variable i
Once an object is declared as a friend, _________________________.
- A) it has no access to data members of the class
- B) it has access to public members only
- C) it has access to protected data members only
- D) it has access to all non-public members as if they were public
The return type of the overloaded new operator must be?
- A) void (nothing)
- B) void pointer
- C) object pointer
- D) int pointer
The ws manipulator can be used with ______ stream(s).
- A) Input
- B) None of the given options
- C) Input/Output
- D) Output
In C language, the region of memory allocated at runtime is called _______________.
- A) available memory
- B) heap
- C) free store
- D) stack
Suppose we have a data member buf of our String class and we like to refer it in a member function of the same class, then choose which option is incorrect?
- A) (*this).buf
- B) this.(*buf)
- C) buf
- D) this -> buf
Which of the following syntax is best used to delete an array of 5 objects named ‘string’ allocated using new operator.
- A) delete []string ;
- B) delete string[5] ;
- C) delete string ;
- D) delete string[] ;
Overloaded member operator function is always called by _______
- A) Class
- B) Object
- C) Primitive data type
- D) Compiler
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