Google News
logo
CPP - Quiz(MCQ)
A)
Precedence of operators are changed after overlaoding
B)
Associativity and precedence of operators does not change
C)
Only arithmetic operators can be overloaded
D)
Only non-arithmetic operators can be overloaded

Correct Answer : Option (B) :   Associativity and precedence of operators does not change


Explanation : Both arithmetic and non-arithmetic operators can be overloaded. The precedence and associativity of operators remains the same after and before operator overloading.

A)
complex number
B)
complexnum
C)
complexarg
D)
complex

Correct Answer : Option (D) :   complex


Explanation : <complex> header file is used for declaring a complex number in C++.

3 .
What will be the output of the following C++ code?
    #include <iostream>
    #include <complex>
    using namespace std;
    int main ()
    {
        complex<double> mycomplex (20.0, 2.0);
        cout << imag(mycomplex) << endl;
        return 0;
    }
A)
2
B)
20
C)
30
D)
40

Correct Answer : Option (A) :   2


Explaination :

imag part will return the imaginary part of the complex number.

Outpu t:
$ g++ comp5.cpp
$ a.out
2

A)
it is used for storage
B)
result of the type conversion is a valid
C)
result of the type conversion is an invalid
D)
to be used in low memory

Correct Answer : Option (B) :   result of the type conversion is a valid


Explanation :  It is used to check that operators and operands are compatible after conversion.

A)
Stack
B)
Queue
C)
Stack & Queue
D)
memory heap

Correct Answer : Option (C) :   Memory heap


Explanation : Memory heap will store the large objects in c++ if it extends its allocated memory.

A)
delete the objects after processing
B)
rename the objects
C)
both rename & delete the objects
D)
add the objects

Correct Answer : Option (A) :   delete the objects after processing


Explanation : When you allocate memory from the heap, you must remember to clean up objects when you’re done! Failure to do so is called a memory leak.

A)
vector
B)
string
C)
class
D)
string & class

Correct Answer : Option (A) :   vector


Explanation : Because the vector is mainly used to store large objects for the game programming and other operations etc.

A)
pass by value
B)
pass by reference
C)
pass by name
D)
both pass by value & reference

Correct Answer : Option (B) :   pass by reference


Explanation : Because by using pass by reference we need to pass only address location, So it can save a lot of memory.

A)
setflimit()
B)
unlimit()
C)
setrlimit()
D)
both setrlimit() & unlimit()

Correct Answer : Option (C) :   setrlimit()


Explanation : setrlimit() is used to unlimit the size of the stack.

A)
top to bottom
B)
bottom to top
C)
left to right
D)
right to left

Correct Answer : Option (D) :   right to left


Explanation : In assignment operation, the flow of execution will be from right to left only.