Skip to main content

Object Oriented Programming MCQs with Answers

Practice important Object Oriented Programming MCQs with answers and explanations.

Multiple Choice Questions

Q181: How can you access non-static members from a static member function?
  • A: Directly within the static member function
  • B: Through an instance of the class
  • C: By using the this pointer
  • D: It is not possible
View Answer
D

Q182: What is the purpose of using a this pointer in non-static member functions?
  • A: To access static members
  • B: To access non-static members
  • C: To call other static functions
  • D: To modify static data members
View Answer
B

Q183: How do static data members differ from global variables?
  • A: Static members are local to the class
  • B: Global variables are more encapsulated
  • C: Static members can be accessed anywhere in the program
  • D: Global variables have limited scope compared to static members
View Answer
A

Q184: Which of the following statements about static data members is correct?
  • A: They are allocated memory separately for each object
  • B: They are initialized each time a new object is created
  • C: They remain in memory even when all objects are destroyed
  • D: They can be accessed only through instance methods
View Answer
C

Q185: What error occurs if you try to create an array of objects without a default constructor?
  • A: Compilation error
  • B: Runtime error
  • C: Logical error
  • D: No error
View Answer
A

Q186: In the Student class example, what is the result of calling Student::getTotalStudents() if it accesses noOfStudents?
  • A: Returns the number of students
  • B: Causes a compilation error
  • C: Returns 0
  • D: Returns a random value
View Answer
A

Q187: What happens if you access a static data member using a non-static method?
  • A: It is not possible
  • B: It will compile but not work
  • C: It will access the static member correctly
  • D: It will throw a runtime error
View Answer
C

Q188: What is a pointer to an object in C++?
  • A: A pointer that points to built-in types
  • B: A pointer that points to other pointers
  • C: A pointer that points to a class object
  • D: A pointer that points to a function
View Answer
C

Q189: How can you dynamically allocate an object in C++?
  • A: Using the malloc function
  • B: Using the new operator
  • C: Using the calloc function
  • D: Using the delete operator
View Answer
B

Q190: What happens when you use new Student in C++?
  • A: It creates an object on the stack
  • B: It creates an object on the heap
  • C: It creates a global object
  • D: It creates an array of objects
View Answer
B

Test Your Knowledge

Take a timed quiz on Object Oriented Programming

🚀 Start Quiz Now