MCQ Bank
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
The only operator that the compiler overloads for user define data type by default is
- A) Plus (+) operator
- B) Minus (-) operator
- C) Equal (==) operator
- D) Assignment (=) operator
In C++ operators, which of the following operator cannot be overloaded ___________.
- A) -
- B) <<
- C) ?:
- D) +
Which of the following is the correct definition of streams?
- A) It is an unordered sequence of bits
- B) It is an ordered sequence of bytes
- C) It is an ordered sequence of bits
- D) It is an unordered sequence of bytes
What is the sequence of event(s) when allocating memory to an object using new operator?
- A) Only block of memory is allocated for object
- B) Memory is allocated first before calling constructor
- C) Constructor is called first before allocating memory
- D) Only constructor is called for object
date+=1; is equivalent to ______________.
- A) date+1
- B) 1+date
- C) date++
- D) ++date
The friend function of a class can have access _________________.
- A) to the private data members
- B) to the protected data members
- C) to public, private and protected data members
- D) to the public data members only
Which of the following is normally a destination for cin stream?
- A) Mouse
- B) Printer
- C) Keyboard
- D) Variable
The new operator automatically determines the size of memory required to store that object , so it does not need ______________.
- A) dot operator
- B) sizeof operator
- C) free operator
- D) size off operator
Which one of the following is the declaration of overloaded pre-increment operator implemented as member function?
- A) Class-name operator ++(int) ;
- B) Class-name operator ++();
- C) Class-name operator +(int) ;
- D) Class-name operator +() ;