On This Page

This set of CPP Programming Multiple Choice Questions & Answers (MCQs) focuses on Cpp Programming Set 3

Q1 | Which of the following is true about templates?1) Template is a feature of C++ that allows us to write one code for different data types.2) We can write one function that can be used for all data types including user defined types. Like sort(), max(), min(), ..etc.3) We can write one class or struct that can be used for all data types including user defined types. Like Linked List, Stack, Queue,..etc.4) Template is an example of compile time polymorphism.
  • 1 and 2
  • 1, 2 and 3
  • 1, 2 and 4
  • 1, 2, 3 and 4
Q2 | Which of the following is incorrect in C++?(1)When we write overloaded function we must code the function for each usage.(2)When we write function template we code the function only once.(3)It is difficult to debug macros(4)Templates are more efficient than macros
  • (1) and (2)
  • (1), (2) and (3)
  • (3) and (4)
  • All are correct.
Q3 | Pick the odd one out
  • array type
  • character type
  • Boolean type
  • integer type
Q4 | Which data type is used to represent the absence of parameters?
  • int
  • short
  • void
  • float
Q5 | What does an escape code represent?
  • alert
  • backslash
  • tab
  • form feed
Q6 | Which type is best suited to represent the logical values?
  • integer
  • Boolean
  • character
  • all of the mentioned
Q7 | Identify the user-defined types from the following?
  • enumeration
  • classes
  • both enumeration and classes
  • int
Q8 | Which of the following statements are true? int f (float)
  • f is a function taking an argument of type int and returning a floating point number
  • f is a function taking an argument of type float and returning an integer
  • f is a function of type float
  • none of the mentioned
Q9 | The value 132.54 can be represented using which data type?
  • double
  • void
  • int
  • bool
Q10 | When a language has the capability to produce new data type mean, it can be called as …...
  • overloaded
  • extensible
  • encapsulated
  • reprehensible
Q11 | Choose the operator which cannot be overloaded.
  • /
  • ( )
  • ::
  • %
Q12 | Which operator is required to be overloaded as member function only?
  • _
  • _ _
  • #NAME?
  • 0
Q13 | Class function which is called automatically as soon as the object is created is called as __
  • Constructor
  • Destructor
  • Friend function
  • Inline function.
Q14 | Which type of data file is analogous to an audio cassette tape?
  • Random access file
  • Sequential access file
  • Binary file
  • Source code file
Q15 | What is the built in library function to compare two strings?
  • string_cmp()
  • strcmp()
  • equals()
  • str_compare()
Q16 | Which of the following are member dereferencing operators in CPP?1. * 2. :: 3. ->* 4. ::* 5. ->
  • Only 1, 3, 4
  • Only 1 and 5
  • Only 3 and 4
  • Only 3,4,5
Q17 | Which of the followings is/are pointer-to-member declarator?
  • ->*
  • .*
  • ::*
  • both A and B
Q18 | Assigning one or more function body to the same name is called ____________.
  • Function Overriding
  • Function Overloading
  • Both A and B
  • None of the above
Q19 | Default values for a function are specified when ____.
  • Function is defined
  • Function is declared
  • Both a and b
  • None of these
Q20 | Which of the following best defines the syntax for template function?
  • Template
  • Template return_type Function_Name(Parameters)
  • Both a and b
  • None of these
Q21 | Return type of uncaught_exception () is ________________.
  • int
  • bool
  • char *
  • double
Q22 | If inner catch handler is not able to handle the exception then__________.
  • Compiler will look for outer try handler
  • Program terminates abnormally
  • Compiler will check for appropriate catch handler of outer try block
  • None
Q23 | Attempting to throw an exception that is not supported by a function call results in calling _____________ library function.
  • indeterminate ()
  • unutilized()
  • unexpected()
  • unpredicted()
Q24 | The code of statements which may cause abnormal termination of the program should bewritten under_________ block.
  • Try
  • catch
  • Finally
  • None of these
Q25 | When a virtual function is redefined by the derived class, it is called___________.
  • Overloading
  • Overriding
  • Rewriting
  • All of these