Skip to main content

Object Oriented Programming MCQs with Answers

Practice important Object Oriented Programming MCQs with answers and explanations.

Multiple Choice Questions

Q521: What error is shown if my_cast is called without specifying the type parameter?
  • A: Compilation error
  • B: Runtime error
  • C: Logical error
  • D: No error
View Answer
A

Q522: Which solution is the most elegant for case-sensitive and case-insensitive string comparison?
  • A: Writing two separate functions
  • B: Using a single function with a boolean parameter
  • C: Overloading functions
  • D: Using a template with policy classes
View Answer
D

Q523: What does the function isEqual< const char* >( const char* x, const char* y ) do?
  • A: Compares two integer values
  • B: Compares two strings
  • C: Compares two characters
  • D: Converts strings to integers
View Answer
B

Q524: In the compare function, what is the default comparison type if no template argument is provided?
  • A: CaseSenCmp
  • B: NonCaseSenCmp
  • C: Both CaseSenCmp and NonCaseSenCmp
  • D: None of the above
View Answer
A

Q525: The statement void printArray( T* array, int size ) in the function template uses which keyword to handle multiple data types?
  • A: class
  • B: typename
  • C: template
  • D: auto
View Answer
C

Q526: What is the primary benefit of using function templates over function overloading?
  • A: Function templates provide code specialization
  • B: Function templates work with many data types
  • C: Function templates are less readable
  • D: Function templates require more code
View Answer
B

Q527: What is the purpose of the printArray function template?
  • A: Print single values only
  • B: Print arrays only
  • C: Print both single values and arrays
  • D: Print only specific data types
View Answer
C

Q528: What type of programming does the find function use to handle different data types?
  • A: Procedural programming
  • B: Object-oriented programming
  • C: Generic programming
  • D: Functional programming
View Answer
C

Q529: In the find function, what does the beyond parameter represent?
  • A: The end of the container
  • B: The start of the container
  • C: A specific element in the container
  • D: The size of the container
View Answer
A

Q530: Which of the following statements about the find function is TRUE?
  • A: It only works with arrays of integers
  • B: It can work with different data types
  • C: It always returns a pointer to zero
  • D: It requires a fixed-size container
View Answer
B

Test Your Knowledge

Take a timed quiz on Object Oriented Programming

🚀 Start Quiz Now