C++ - Programming Language (MCQ) questions

Dear Readers, Welcome to C++ multiple choice questions and answers with explanation. These objective type C++ questions are very important for campus placement test and job interviews.

Specially developed for the C++ freshers and professionals, these model questions are asked in the online technical test and interview of many IT companies.

1)   C++: The derivation of Child class from Base class is indicated by ____ symbol.
- Published on 29 Jun 15

a. ::
b. :
c. ;
d. |
Answer  Explanation 

ANSWER: :

Explanation:
No explanation is available for this question!


2)   C++: During a class inheritance in CPP, if the visibility mode or mode of derivation is not provided, then by default visibility mode is___________.

- Published on 29 Jun 15

a. public
b. protected
c. private
d. friend
Answer  Explanation 

ANSWER: private

Explanation:
The private keyword specifies that the members are accessible only from member functions and friends of the class.


3)   Java: Generic pointers can be declared with__________
- Published on 29 Jun 15

a. auto
b. void
c. asm
d. None of these
Answer  Explanation 

ANSWER: void

Explanation:
When a variable is declared as being a pointer to type void it is known as a generic pointer. We cannot have a void type of variable so the pointer will not point to any data and therefore it cannot be dereferenced. Still it is a pointer and to use it you just need to cast it to another kind of pointer.


4)   Java: Predict the output:

int x = 786;
cout << setfill(‘*’) << setw(6) << x;

- Published on 29 Jun 15

a. 786***
b. **786
c. ***786
d. ******
Answer  Explanation 

ANSWER: ***786

Explanation:
When set() manipulator is used, then output is right justified. So Out of 6 width, 3 are used by variable x and remaining 3 width (Spaces) are filled with char * due to setfill().


5)   ______________are used to format the data display in CPP?
- Published on 29 Jun 15

a. Iterators
b. Punctuators
c. Manipulators
d. Allocators
Answer  Explanation 

ANSWER: Manipulators

Explanation:
Manipulators are functions which are specifically designed to be used with conjunction with the insertion (<<) and extraction (>>) operators. They are used to change the formatting parameters on streams and insert or extract certain special characters.


6)   C++: Which of the following is\are correct statements about inline function and macros.
- Published on 19 Oct 15

a. Inline functions are parsed by the compiler but Macros are expanded by the C++ preprocessor.
b. Inline functions follow strict parameter type checking.
c. Macros do not follow parameter type checking.
d. All of the above.
Answer  Explanation 

ANSWER: All of the above.

Explanation:
No explanation is available for this question!


7)   C++: Trace the output

void execute (int x, int y = 200)
{
Int temp = x + y;

x +=temp;
if (y!= 200)
cout << temp << ”  ” << x << ”  ” << y << ”  ” << endl;
}
void main ( )
{

int a = 50, b = 20;
execute (b);
cout << a << ”  ” << b << ”  ” << endl;
execute (a, b);
}

- Published on 19 Oct 15

a.
2202050
50 20
b.
50 20
70 120 20
c. 20 200
d. None of the above.
Answer  Explanation 

ANSWER:
50 20
70 120 20

Explanation:
No explanation is available for this question!


8)   C++: What is RTTI?
- Published on 19 Oct 15

a. Run-Time Type Identification (RTTI) is a technique that is used to know the type of any object at run time.
b. RTTI is a technique that is used to know the type of any object at compile time.
c. RTTI reserve memory of function at run time.
d. None of the above.
Answer  Explanation 

ANSWER: Run-Time Type Identification (RTTI) is a technique that is used to know the type of any object at run time.

Explanation:
No explanation is available for this question!


9)   C++: The Standard Template Library (STL) consists of three main components. What are those components?
- Published on 19 Oct 15

a. ADT, Structure,class.
b. Containers, Algorithms, and statements.
c. Containers, Algorithms, and Iterators.
d. None of the above.
Answer  Explanation 

ANSWER: Containers, Algorithms, and Iterators.

Explanation:
No explanation is available for this question!


10)   C++: Which of the following is\are true about virtual function?
- Published on 19 Oct 15

a. Function call is resolved at run-time
b. It is member function of a class.
c. Generally has a different functionality in the derived class.
d. All of the above.
Answer  Explanation 

ANSWER: All of the above.

Explanation:
No explanation is available for this question!


1 2 3 4 5