Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Multiple Choice Questions
Q461: What does static binding mean in C++?
- A: The target function for a call is selected at runtime.
- B: The target function for a call is selected at compile time.
- C: The function cannot be overridden.
- D: The function is determined based on user input.
View Answer
B
Q462: Fill in the blank: In C++, dynamic binding is achieved through the use of ________ functions.
- A: friend
- B: static
- C: virtual
- D: inline
View Answer
C
Q463: What is the purpose of the calcArea method in the shape hierarchy?
- A: To calculate the area of shapes.
- B: To draw the shape.
- C: To determine the type of shape.
- D: To store the shape's dimensions.
View Answer
A
Q464: Which of the following is NOT a derived class of Shape in the provided hierarchy?
- A: Rectangle
- B: Line
- C: Circle
- D: Triangle
View Answer
A
Q465: Why is delocalized code considered problematic in the shape hierarchy implementation?
- A: It simplifies code readability.
- B: It causes redundant code in multiple places, leading to potential errors.
- C: It increases the efficiency of the program.
- D: It makes the code easier to maintain.
View Answer
B
Q466: What output would you expect if the draw method in Shape class is not virtual and you try to draw a Circle stored in a Shape pointer array?
- A: "Circle"
- B: "Shape"
- C: "Line"
- D: "Triangle"
View Answer
B
Q467: What is the main concept of Polymorphism?
- A: The ability to use the same method name for different objects
- B: The ability to inherit multiple classes
- C: The ability to override methods in derived classes
- D: The ability to instantiate abstract classes
View Answer
A
Q468: What is an Abstract Class?
- A: A class with no methods
- B: A class that cannot be instantiated directly
- C: A class that contains only public methods
- D: A class that inherits from multiple base classes
View Answer
B
Q469: How do you declare a Pure Virtual Function in C++?
- A: virtual void functionName() = 0;
- B: virtual void functionName() { }
- C: virtual void functionName();
- D: virtual void functionName() = 1;
View Answer
A
Q470: Which of the following statements is true about Virtual Destructors?
- A: A base class destructor must be made virtual to avoid memory leaks when deleting derived class objects.
- B: The destructor of derived classes is always called before the base class destructor.
- C: Derived class destructors must be declared as pure virtual functions.
- D: A base class destructor must be private to avoid memory leaks.
View Answer
A