MCQ Bank
How many objects are initializing in this statement of code: Date myDate [10] = { Date(09, 03, 1970), Date(08, 23, 1974) }
- A) 3
- B) 2
- C) 10
- D) 1
What is the output of the following code if the user enters 10? #include <iostream> using namespace std; int main() { int num; cout << "Enter a number: "; cin >> num; cout << "Output: " << num + 5; return 0; }
- A) 50
- B) 105
- C) 15
- D) 10
Which header file is used for file manipulation?
- A) iomanip.h
- B) filestream.h
- C) fstream.h
- D) iostream.h
Which option will be correct in order to free the space of memory allocated to a buffer (buf)?
- A) strcpy buf
- B) delete buf
- C) remove buf
- D) free buf
Which of the following options not a source of the output stream?
- A) simple variable
- B) region in the memory
- C) file
- D) screen
For overloading minus (-) operator, which member operator function will be correct?
- A) Complex operator – (Complex c)
- B) Complex operator (complex c1- complex c2)
- C) Complex – operator (Complex c)
- D) Complex (-) operator (Complex c)
Which of the following operator can be overloaded?
- A) .*
- B) .
- C) ?
- D) delete[]
How many objects are created for the class Date? Date myDates[10] ;
- A) 0
- B) 10
- C) 1
- D) 5
Which of the following option returns the state of end of file?
- A) cin.enof();
- B) cin.endoffile();
- C) cin.endof();
- D) cin.eof();
What is the correct prototype of overloading of delete operator?
- A) void operator delete ( void * ptr) ;
- B) void * operator delete ( size_t size ) ;
- C) new operator delete ( void * ptr);
- D) void * operator delete ( size_t, size ) ;
What is the output of this program? #include < iostream > using namespace std; main () { int num; cout << "Please enter an integer value: "; cin >> num + 4; }
- A) Error
- B) Add number+4
- C) 4+1
- D) 4
Which of the following correctly initializes the 3rd object of the Date class in the array mydate?
- A) mydate[2] = Date(10, 10, 2021);
- B) Date mydate[2] = Date(10, 10, 2021);
- C) mydate[3] = Date(3, 3, 2021);
- D) Date mydate[3] = Date(10, 10, 2021);
Which of the following operator cannot be overloaded in C++ language?
- A) ++
- B) sizeof
- C) ||
- D) --
Which one is not the member function of input stream?
- A) cin.read();
- B) cin.get();
- C) cin.getline();
- D) get();
Complex cadd ( Complex c1, Complex c2 ) ; Which statement is true for above code?
- A) It accepts two complex numbers as parameters and returns back the resultant complex number.
- B) Define the function named Complex.
- C) Class with name of Complex has been created.
- D) Creating object of class Complex with name cadd with parameters.
What is the right syntax of the buf for calling object by using this pointer?
- A) (*this).buf
- B) *this.(buf)
- C) this*buf
- D) *this.buf
What would be the output of the following statement? c = 13 % 2;
- A) 3
- B) 2
- C) 0
- D) 1
What will be the output of the following code? void sampleFunction(int = 5,float = 4.1, char = 'A'); int main(){ sampleFunction(50,3.2); } void sampleFunction(int one,float two ,char three) { cout << one << ", " << two << ", " << three; }
- A) 50, 3.2, A
- B) 5, 4.1, A
- C) 50, 4.1, A
- D) 5, 3.2, A
What is the output of the following code if the user enters 10? #include <iostream> using namespace std; int main() { int num; cout << "Enter a number: "; cin >> num; cout << "Output: " << num + 5; return 0; }
- A) 105
- B) 15
- C) 10
- D) 50
if (day == daysOfMonth ( *this ) ) { } In above code, *this refers to:
- A) Any Object
- B) Current Object
- C) Current Class
- D) Today Date and Time