MCQ Bank
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
A class can be declared as a __________________ of other class.
- A) part
- B) member function
- C) friend
- D) member
A _____________ function of a class is defined outside that class scope, but it can access all private and protected members of the class.
- A) Protected
- B) Private
- C) Friend
- D) Global
If we want to allocate memory to an array of 5 integers dynamically, the syntax will be _____________.
- A) integer iptr** ; iptr= new int[5]
- B) int *iptr ; iptr = new int[5] ;
- C) int iptr ; iptr= int [5]
- D) iptr= new[5]
public or private keywords can be ______________
- A) written only for once in the class or structure declaration
- B) written multiple times in the class or structure declaration
- C) written only twice in the class declaration
- D) written outside the class
The concept of friend function negates the concept of _________________.
- A) encapsulation
- B) inheritance
- C) polymorphism
- D) persistence
What is the function of the following statement to delete an array of 5 objects named ‘arr’ allocated using new operator?
delete arr ;
- A) Do not delete any object
- B) Deletes only one object of array
- C) Deletes all the objects of array
- D) Results into syntax error
Operator overloading is to allow the same operator to be bound to more than one implementation, depending on the types of the _________.
- A) Compilers
- B) Operands
- C) Function names
- D) Applications
What happens when new is called to create an object?
- A) Only memory is allocated (no constructor call).
- B) The object is immediately destroyed.
- C) Memory is allocated, and the constructor is called
- D) The destructor is called automatically.
What is the difference between cout and cerr?
- A) cout is unbuffered output and cerr is buffered output
- B) cout is buffered output and cerr is unbuffered output
- C) cout is standard output and cerr is not a standard output
- D) cout is not a standard output and cerr is standard output
When we used eof (end of file) with the file reading than which of the following is a true statement?
- A) This is way to check type of the stream
- B) This is way to check source of the stream
- C) This is way to check destination of the stream
- D) This is way to check state of the stream
_____________data isn't accessible by non-member functions or outside classes
- A) Public
- B) Static
- C) private
- D) Globally declared