Skip to main content

Object Oriented Programming MCQs with Answers

Practice important Object Oriented Programming MCQs with answers and explanations.

Multiple Choice Questions

Q211: To create an array of Date objects, you need _______ constructor.
  • A: Default constructor
  • B: Destructor
  • C: Copy constructor
  • D: Static constructor
View Answer
A

Q212: The setMonth method in the Date class validates the month to be between _______ and _______.
  • A: 0 and 12
  • B: 1 and 12
  • C: 1 and 31
  • D: 0 and 31
View Answer
B

Q213: A static member function in the Date class _______ non-static members.
  • A: Cannot access
  • B: Can modify
  • C: Can access directly
  • D: Can access indirectly
View Answer
A

Q214: The addDay method in the Date class adds _______ to the current day.
  • A: A specified number of days
  • B: A specified number of months
  • C: A specified number of years
  • D: The default number of days
View Answer
A

Q215: To allocate memory for an array of Student objects, you use _______.
  • A: new Student[100]
  • B: malloc(100 * sizeof(Student))
  • C: new Student()
  • D: new Student
View Answer
A

Q216: In object-oriented programming, what does composition imply about the relationship between objects?
  • A: One object inherits from another
  • B: One object contains another object
  • C: One object executes methods of another
  • D: One object replaces another
View Answer
B

Q217: When using dynamic memory allocation for a class member in C++, what operator is used to allocate memory?
  • A: delete
  • B: new
  • C: free
  • D: allocate
View Answer
B

Q218: Which of the following is a correct way to allocate an array of objects using the new operator in C++?
  • A: Student *ptr = new Student[100];
  • B: Student ptr = new Student[100];
  • C: Student *ptr = new Student(100);
  • D: Student ptr = new Student(100);
View Answer
A

Q219: In the Student class, what function is used to initialize a new student's name?
  • A: SetName()
  • B: GetName()
  • C: SetRollNo()
  • D: GetRollNo()
View Answer
A

Q220: What does the destructor in the Student class do?
  • A: Allocates memory for the name variable
  • B: Deletes the memory allocated for the name variable
  • C: Initializes the name variable
  • D: Changes the roll number
View Answer
B

Test Your Knowledge

Take a timed quiz on Object Oriented Programming

🚀 Start Quiz Now