MCQ Bank
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
Which of the following concept is NOT associated with stream?
- A) Destination
- B) State
- C) Source
- D) Template
dec, hex, oct are all __________
- A) Objects of input/output streams
- B) Parameterized manipulators
- C) Member functions
- D) Non-parameterized manipulators
What is meant by the following statement?.
String str[5] = {String(“Programming”), String(“CS201”)};
- A) Parameterized constructor will call for first 2 objects and default constructor for remaining objects
- B) Default constructor will be called for all objects of array
- C) Parameterized constructor will be called for all objects of array
- D) Default constructor will call for first 2 objects and parameterized constructor for remaining objects
If text is a pointer of type String then what will be the functionality of following statement?
text = new String [5];
- A) Creates array of 5 objects dynamically
- B) Creates a string Object
- C) Creates array of pointers to string
- D) Creates array of 5 objects statically
Identify the correct method of adding two strings, s1 and s2.
- A) s1+s2
- B) strcat(s1, s2);
- C) s1+s2 and strcat(s1,s2)
- D) s1, s2+
When we use cin stream to read some number from the keyboard and store it in the integer variable, then what will happen?
- A) Some error will occur and cin stream will detect this error.
- B) Its ASCII code will be stored inside the computer
- C) Its binary representation will be ignored and the value will be stored
- D) Its binary representation will be ignored and the character will be stored
Choose the operator which cannot be overloaded in C++.
- A) &
- B) ~
- C) | |
- D) ?
In the scenario, if we want to grant access to the private data members of a Class1 to the Class2, then which statement is true about this scenario?
- A) Class1 is required to be friend of Class2
- B) Class2 inherits from Class1
- C) Class1 inherits from Class2
- D) Class2 is required to be friend of Class1
Friend functions are _____________.
- A) unidirectional
- B) private
- C) bidirectional
- D) public