Skip to main content

Object Oriented Programming MCQs with Answers

Practice important Object Oriented Programming MCQs with answers and explanations.

Multiple Choice Questions

Q171: The Student class member const int rollNo cannot be modified in which part of the class?
  • A: Constructor
  • B: Member functions
  • C: Static methods
  • D: Initializer list
View Answer
B

Q172: In the Student class example, how is the static int noOfStudents variable initialized?
  • A: Inside the class definition
  • B: At the time of definition outside the class
  • C: In the constructor
  • D: Through a member function
View Answer
B

Q173: What is a primary benefit of using constant member functions?
  • A: They allow modification of object state
  • B: They prevent modification of object state
  • C: They increase execution speed
  • D: They reduce memory usage
View Answer
B

Q174: What is a static data member in a class?
  • A: A variable specific to each object
  • B: A variable shared by all instances of the class
  • C: A variable only accessible within member functions
  • D: A global variable
View Answer
B

Q175: How are static data members initialized in C++?
  • A: Inside the class definition
  • B: Outside the class definition
  • C: In the constructor
  • D: Through a member function
View Answer
B

Q176: What is the main benefit of using static data members?
  • A: They belong to each object
  • B: They are initialized each time an object is created
  • C: They are shared by all instances of the class
  • D: They can be modified by any object
View Answer
C

Q177: What happens if a static data member is not explicitly initialized?
  • A: It causes a compilation error
  • B: It is initialized to a random value
  • C: It is initialized to 0
  • D: It remains uninitialized
View Answer
C

Q178: Which operator is used to access a static data member?
  • A: Dot operator (.)
  • B: Scope resolution operator (::)
  • C: Arrow operator (->)
  • D: Member access operator (.)
View Answer
B

Q179: In the provided Student class example, how is the noOfStudents data member accessed?
  • A: Student::noOfStudents
  • B: aStudent.noOfStudents
  • C: Student.getTotalStudents()
  • D: aStudent.getTotalStudents()
View Answer
A

Q180: What is a static member function in C++?
  • A: A function that operates on individual objects
  • B: A function that does not require an object to be invoked
  • C: A function that accesses non-static members
  • D: A function that modifies static data members
View Answer
B

Test Your Knowledge

Take a timed quiz on Object Oriented Programming

🚀 Start Quiz Now