CPP MCQ SET


C++ MULTIPLE CHOICE QUESTION SET

[1] Which feature in OOP allows reusing code?
(A) => Polymorphism
(B) => Inheritance
(C) => Encapsulation
Answer =>> Inheritance

[2] A function that changes the state of the cout object is called a(n) _____
(A) => member
(B) => adjuster
(C) => manipulator
Answer =>> manipulator

[3] What does C++ append to the end of a string literal constant?
(A) => a space
(B) => a number sign (#)
(C) => a null character
Answer =>> a null character

[4] An array element is accessed using
(A) => a first-in-first-out approach
(B) => the dot operator
(C) => an index number
Answer =>> an index number

[5] To hide a data member from the program, you must declare the data member in the _____ section of the class
(A) => concealed
(B) => hidden
(C) => private
Answer =>> private

[6] External documentation includes
(A) => a printout of the program's code
(B) => flowcharts
(C) => IPO charts
Answer =>> a printout of the program's code

[7] The function whose prototype is void getData(Item *thing); receives
(A) => a pointer to a structure
(B) => a reference to a structure
(C) => a copy of a structure
Answer =>> a pointer to a structure

[8] Null character needs a space of
(A) => zero bytes
(B) => one byte
(C) => three bytes
Answer =>> one byte

[9] The number of structures than can be declared in a single statement is
(A) => one
(B) => two
(C) => unlimited
Answer =>> unlimited

[10] Which of the following formulas can be used to generate random integers between 1 and 10?
(A) => 1 + rand() % (10 - 1 + 1)
(B) => 1 + (10 - 1 + 1) % rand()
(C) => 10 + rand() % (10 - 1 + 1)
Answer =>> 1 + rand() % (10 - 1 + 1)

[11] Format flags may be combined using the _____
(A) => bitwise OR operator (|)
(B) => logical OR operator (||)
(C) => bitwise AND operator (&)
Answer =>> bitwise OR operator (|)

[12] Which of the following will store the number 320000 as a Float number?
(A) => counPop = (float) 3.2e5;
(B) => counPop = (float) 3.2e6;
(C) => counPop = (float) .32e5;
Answer =>> counPop = (float) 3.2e5;

[13] The arguments that determine the state of the cout object are called
(A) => classes
(B) => manipulators
(C) => format flags or state flags
Answer =>> format flags or state flags

[14] The following statement where T is true and F is false T&&T||F&&T
(A) => is true
(B) => is false
(C) => is wrong
Answer =>> is true

[15] Which of the following statements declares a variable that can contain a decimal number?
(A) => dec payRate;
(B) => dec hourlyPay
(C) => float hourlyPay;
Answer =>> float hourlyPay;

[16] The statement int num[2][3]={ {1,2}, {3,4}, {5, 6} };
(A) => assigns a value 2 to num[1][2]
(B) => gives an error message
(C) => assigns a value 4 to num[1][2]
Answer =>> gives an error message

[17] A program will have one function prototype for each function defined in the programmerdefined section of the program. (Assume that the programmer-defined section is located below the main function.)
(A) => true
(B) => false
(C) => none
Answer =>> true

[18] The standard input stream, which refers to the keyboard, is called
(A) => cin
(B) => cout
(C) => stin
Answer =>> cin

[19] Elements in an array are identified by a unique _____
(A) => data type
(B) => order
(C) => subscript
Answer =>> subscript

[20] The statement fwrite ( (char*)&objl, sizeof(objl) );
(A) => writes the member functions of objl to fl
(B) => writes the data in objl to fl
(C) => writes the member functions and me data of obj 1 to fl
Answer =>> writes the data in objl to fl

[21] The body of a C++ function is surrounded by _____
(A) => parentheses
(B) => angle brackets
(C) => curly brackets
Answer =>> angle brackets

[22] Which of the following type casts will convert an Integer variable named amount to a Double type?
(A) => (double) amount
(B) => (int to double) amount
(C) => int to double(amount)
Answer =>> (double) amount

[23] The loosest type of coupling is
(A) => data coupling
(B) => control coupling
(C) => external coupling
Answer =>> data coupling

[24] Which of the following is a string literal constant?
(A) => “Visual C++”
(B) => “137.45”
(C) => All of the above
Answer =>> All of the above

[25] Which of the following, if any, are valid names for variables?
(A) => class
(B) => friend
(C) => None of the above is valid names for variables
Answer =>> None of the above is valid names for variables

[26] You have assigned the address of Value to the pointer P, Which statement will display the value stored in Value?
(A) => cout<
(B) => cout<<*
(C) => cout<<&P;
Answer =>> cout<<*


[27] The void specifier is used if a function does not have return type
(A) => True
(B) => False
(C) => none
Answer =>> True

[28] You must specify void in parameters if a function does not have any arguments
(A) => True
(B) => False
(C) => none
Answer =>> False

[29] Type specifier is optional when declaring a function
(A) => True
(B) => False
(C) => none
Answer =>> False

[30] A pointer to a block of memory is effectively same as an array
(A) => True
(B) => False
(C) => none
Answer =>> True

[31] Does this mentioning array name gives the base address in all the contexts?
(A) => Yes
(B) => No
(C) => none
Answer =>> True

[32] Is there any difference int the following declarations? int fun(int arr[]); int fun(int arr[2]);
(A) => Yes
(B) => No
(C) => none
Answer =>> No

[33] Are the expressions arr and &arr same for an array of 10 integers?
(A) => Yes
(B) => No
(C) => none
Answer =>> No

[34] The keyword used to transfer control from a function back to the calling function is
(A) => switch
(B) => goto
(C) => return
Answer =>> switch

[35] The directives for the preprocessors begin with
(A) => Ampersand symbol (&)
(B) => Two Slashes (//)
(C) => Number Sign (#)
Answer =>> Number Sign (#)

[36] The file iostream includes
(A) => The declarations of the basic standard input-output library.
(B) => The streams of includes and outputs of program effect.
(C) => Both of these
Answer =>> The declarations of the basic standard input-output library.

[37] There is a unique function in C++ program by where all C++ programs start their execution
(A) => Start()
(B) => Begin()
(C) => Main()
Answer =>> Main()

[38] Every function in C++ are followed by
(A) => Parameters
(B) => Parenthesis
(C) => Curly braces
Answer =>> Parenthesis

[39] Which of the following is false?
(A) => Cout represents the standard output stream in c++.
(B) => Cout is declared in the iostream standard file
(C) => None of above
Answer =>> None of above

[40] Every statement in C++ program should end with
(A) => A full stop (.)
(B) => A Comma (,)
(C) => A Semicolon
Answer =>> A Semicolon

[41] Which of the following statement is true about preprocessor directives?
(A) => These are lines read and processed by the preprocessor
(B) => They do not produce any code by themselves
(C) => They end with a semicolon
Answer =>> They end with a semicolon

[42] A block comment can be written by
(A) => Starting every line with double slashes (//)
(B) => Starting with /* and ending with */
(C) => Starting with //* and ending with *//
Answer =>> Starting with /* and ending with */

[43] When writing comments you can
(A) => Use code and /* comment on the same line
(B) => Use code and // comments on the same line
(C) => Use code and //* comments on the same line
Answer =>> Use code and // comments on the same line

[44] A variable is/are
(A) => String that varies during program execution
(B) => A portion of memory to store a determined value
(C) => Those numbers that are frequently required in programs
Answer =>> A portion of memory to store a determined value

[45] Which of the following can not be used as identifiers?
(A) => Letters
(B) => Digits
(C) => Spaces
Answer =>> Spaces

[46] Which of the following identifiers is invalid?
(A) => Papername
(B) => Writername
(C) => typename
Answer =>> typename

[47] Which of the following is not a valid escape code?
(A) => \t
(B) => \v
(C) => \w
Answer =>> \w

[48] In an assignment statement
(A) => The lvalue must always be a variable
(B) => The rvalue might be a constant, a variable, an expression or any combination of these
(C) => All of above
Answer =>> All of above

[49] All of the following are valid expressions in C++ a = 2 + (b = 5); a = b = c = 5; a = 11 % 3
(A) => True
(B) => False
(C) => None
Answer =>> True

[50] To increase the value of c by one which of the following statement is wrong?
(A) => c++;
(B) => c = c + 1;
(C) => c + 1 => c;
Answer =>> c + 1 => c;

[51] The result of a Relational operation is always
(A) => Either True or False
(B) => Is less than or is more than
(C) => Is equal or less or more
Answer =>> Either True or False

[52] Which of the following is not a valid relational operator?
(A) => ==
(B) => =>
(C) => >=
Answer =>> =>

[53] When does the code block following while(x<100 data-blogger-escaped-b="" data-blogger-escaped-execute="">
(A) => When x is less than one hundred
(B) => When x is greater than one hundred
(C) => When x is equal to one hundred
Answer =>> When x is less than one hundred

[54] Which is not a loop structure?
(A) => for
(B) => while
(C) => repeat until
Answer =>> repeat until

[55] How many times is a do while loop guaranteed to loop?
(A) => 0
(B) => 1
(C) => Identify
Answer =>> 1

[56] Streams are
(A) => Abstraction to perform input and output operations in sequential media
(B) => Abstraction to perform input and output operations in direct access media
(C) => Both
Answer =>> Abstraction to perform input and output operations in sequential media

[57] Which of the following is known as insertion operator?
(A) => ^
(B) => v
(C) => <<
Answer =>> <<

[58] Regarding the use of new line character (/n) and endl manipulator with cout statement
(A) => Both ways are exactly same
(B) => Both are similar but endl additionally performs flushing of buffer
(C) => Endl can’t be used with cout
Answer =>> Both are similar but endl additionally performs flushing of buffer

[59] Which of the following is output statement in C++?
(A) => print
(B) => write
(C) => cout
Answer =>> cout

[60] Which of the following is input statement in C++?
(A) => Cin
(B) => input
(C) => get
Answer =>> Cin

[61] By default, the standard output device for C++ programs is
(A) => Printer
(B) => Monitor
(C) => Modem
Answer =>> Monitor

[62] By default, the standard input device for C++ program is
(A) => Keyboard
(B) => Mouse
(C) => Scanner
Answer =>> Keyboard

[63] Which of the following statement is true regarding cin statement?
(A) => cin statement must contain a variable preceded by >> operator
(B) => cin does not process the input until user presses RETURN key
(C) => All of the above.
Answer =>> All of the above.

[64] Which of the following is extraction operator in C++?
(A) => ^
(B) => v
(C) => >>
Answer =>> >>

[65] When requesting multiple datum, user must separate each by using
(A) => A space
(B) => A tab character
(C) => All of the above
Answer =>> All of the above

[66] Cin extraction stops execution as soon as it finds any blank space character
(A) => true
(B) => false
(C) => None
Answer =>> true

[67] Observe the following statements and decide what do they do. stringmystring; 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
Answer =>> Reads a line of string from cin into mystring

[68] Regarding stringstream identify the invalid statement
(A) => Stringstream is defined in the header file
(B) => It allows string based objects treated as stream
(C) => None of above
Answer =>> None of above

[69] Which of the header file must be included to use stringstream?
(A) =>
(B) =>
(C) =>
Answer =>>

[70] Which of the following header file does not exist?
(A) =>
(B) =>
(C) =>
Answer =>>

[71] 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
Answer =>> The second input overwrites the first one

[72] 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.
Answer =>> The program worked as expected without any errors during its execution

[73] Which of the following is not a reserve keyword in C++?
(A) => readable
(B) => Default
(C) => Mutable
Answer =>> readable

[74] The size of following variable is not 4 bytes in 32 bit systems
(A) => int
(B) => long int
(C) => Short int
Answer =>> Short int

[75] 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) => Local variables are declared in the main body of the program and accessible only from functions.
Answer =>> Local variables are declared inside a function and accessible within the function only.

[76] Find out the error in following block of code. If (x = 100) Cout<< “x is 100”;
(A) => 100 should be enclosed in quotations
(B) => There is no semicolon at the end of first line
(C) => Equals to operator mistake
Answer =>> Equals to operator mistake

[77] Looping in a program means
(A) => Jumping to the specified branch of program
(B) => Repeat the specified lines of code
(C) => Both of above
Answer =>> Repeat the specified lines of code

[78] The difference between while structure and do structure for looping is
(A) => In while statement the condition is tested at the end of first iteration
(B) => In do structure the condition is tested at the beginning of first iteration
(C) => In while structure condition is tested before executing statements inside loop whereas in do structure condition is tested before repeating the statements inside loop
Answer =>> In while structure condition is tested before executing statements inside loop whereas in do structure condition is tested before repeating the statements inside loop

[79] Which of the following is not a jump statement in C++?
(A) => break
(B) => goto
(C) => switch
Answer =>> switch

[80] Which of the following is selection statement in C++?
(A) => break
(B) => goto
(C) => switch
Answer =>> switch

[81] The continue statement
(A) => Resumes the program if it is hanged
(B) => Skips the rest of the loop in current iteration
(C) => All of the above
Answer =>> Skips the rest of the loop in current iteration

[82] The void specifier is used if a function does not have return type.
(A) => True
(B) => False
(C) => None
Answer =>> True

[83] Simple present tense denotes an action which taking place in which Time.
(A) => Future time
(B) => Past time
(C) => Daily routine
Answer =>> Daily routine

[84] Simple present tense which verb is use.
(A) => Meet
(B) => Meeting
(C) => Met
Answer =>> Meet

[85] Which word is use in present perfect tense?
(A) => Just
(B) => Already
(C) => A , B both
Answer =>> A , B both