Pages

Thursday, January 13, 2011

(MCQs) - Multiple Choice Questions - MCQs from C++ set - 6

Question 1:

 
cin extraction stops execution as soon as it finds any blank space character
 
a.       true
b.      false
 

Question 2:

 
Observe the following statements and decide what do they do.
 
string mystring;
 
getline(cin, mystring);
 
a.       reads a line of string from cin into mystring
b.      reads a line of string from mystring into cin
c.       cin can’t be used this way
d.      none of above
 

Question 3:

 
Regarding stringstream identify the invalid statement
 
a.       stringstream is defined in the header file <sstream>
b.      It allows string based objects treated as stream
c.       It is especially useful to convert strings to numerical values and vice versa.
d.      None of above
 

Question 4:

 
Which of the header file must be included to use stringstream?
 
a.       <iostream>
b.      <string>
c.       <sstring>
d.      <sstream>
 

Question 5:

 
Which of the following header file does not exist?
 
a.       <iostream>
b.      <string>
c.       <sstring>
d.      <sstream>
 

Question 6:

 
If you use same variable for two getline statements
 
a.       Both the inputs are stored in that variable
b.      The second input overwrites the first one
c.       The second input attempt fails since the variable already got its value
d.      You can not use same variable for two getline statements
 
 

Question 7:

 
The “return 0;” statement in main function indicates
 
a.       The program did nothing; completed 0 tasks
b.      The program worked as expected without any errors during its execution
c.        not to end the program yet.
d.      None of above
 

Question 8:

 
Which of the following is not a reserve keyword in C++?
 
a.       mutable
b.      default
c.       readable
d.      volatile
 

Question 9:

 
The size of following variable is not 4 bytes in 32 bit systems
 
a.       int
b.      long int
c.       short int
d.      float
 

Question 10:

 
Identify the correct statement regarding scope of variables
 
a.       Global variables are declared in a separate file and accessible from any program.
b.      Local variables are declared inside a function and accessible within the function only.
c.       Global variables are declared inside a function and accessible from anywhere in program.
d.      Local variables are declared in the main body of the program and accessible only from functions.


Answers



1.       a. True
2.       a. Reads a line of string from cin into mystring
3.       d. None of above
4.       d. <sstream>
5.       c. <sstring>
6.       b. The second input overwrites the first one
7.       b. The program worked as expected without any errors during its execution
8.       c. readable
9.       c. short int
10      b. Local variables are declared inside a function and accessible within the function o

1 comment:

  1. Natural herbal Remedies…. for a herpes cure.

    Robinsonbuckler11[ ] gmail com………
    ___________________

    I am so happy,..i am cured from herpes…it works…

    Thank you so much

    ReplyDelete