Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Multiple Choice Questions
Q201: The setDay method of the Date class accepts a day value and _______.
- A: Sets it as a default day
- B: Checks if it is a valid day
- C: Adds it to the current day
- D: Initializes the day to zero
View Answer
B
Q202: In the Date class, the setDate method does what?
- A: Sets the day, month, and year to default
- B: Sets the day, month, and year and displays the date
- C: Adds days, months, and years to the current date
- D: Deletes the Date object
View Answer
B
Q203: The Date class uses a static member to store _______.
- A: The default date
- B: The current date
- C: The number of Date objects
- D: The day of the month
View Answer
A
Q204: A class with an array of objects must have a _______ if an explicit initializer is not provided.
- A: Default constructor
- B: Destructor
- C: Static member
- D: Static function
View Answer
A
Q205: The main function in the provided code creates a Date object with default values using _______.
- A: Date aDate(0, 0, 0);
- B: Date aDate;
- C: Date aDate(20, 10, 2011);
- D: Date aDate = Date();
View Answer
A
Q206: Static member functions can access _______ members of the class.
- A: Static
- B: Non-static
- C: Private
- D: Protected
View Answer
A
Q207: A static member variable in a class is initialized _______.
- A: Inside the class definition
- B: In the class constructor
- C: Outside the class definition
- D: In the class destructor
View Answer
C
Q208: The Date class destructor prints _______ when a Date object is destroyed.
- A: "Date destructor"
- B: "Object destroyed"
- C: "Date deleted"
- D: "Destructor invoked"
View Answer
A
Q209: The Date class uses the leapYear function to _______.
- A: Determine if the year is a leap year
- B: Calculate the number of leap years
- C: Set the year as a leap year
- D: Add leap days to the year
View Answer
A
Q210: The setDefaultDate method in the Date class is used to _______.
- A: Set the default date for all Date objects
- B: Update the date of a specific object
- C: Delete the default date
- D: Set the day, month, and year of a new object
View Answer
A