C++ MCQs with explanations

Principles of Object-Oriented Programming

1. Which of the following languages is not a pure Object-Oriented language?

Explanation ≡ Correct answer: option c) Ada
Ada is not considered a pure object-oriented language as it also supports procedural programming features. Pure object-oriented languages emphasize objects and classes as the primary means of organizing and modeling data and behavior.

2. Which of the languages is a pure object-oriented language?

Explanation ≡ Correct answer: option b) Smalltalk
Smalltalk is considered a pure object-oriented language as it relies solely on objects and classes for programming. It has no separate support for procedural programming.

3. Which of the following statements is TRUE with respect to object-oriented programming?

Explanation ≡ Correct answer: option d) Data and functions that operate on them are tied together.
Object-oriented programming emphasizes the concept of encapsulation, where data and the functions that operate on that data are packaged together in objects. This ensures that data and behavior are closely related and interact through well-defined interfaces.

4. Which of the following issues is considered as the major drawback of the procedure – oriented programming?

Explanation ≡ Correct answer: option c) Most of the functions share global data.
In procedure-oriented programming, functions often share global data, leading to potential issues with data integrity and difficulty in maintaining the code as the program grows in size and complexity.

5. One of the major advantages of object-oriented programming approach is:

Explanation ≡ Correct answer: option a) It can easily map real-world problems.
Object-oriented programming provides a natural way to model and represent real-world problems and entities, making it easier to understand, design, and maintain software systems that closely mirror real-world scenarios.

6. The wrapping up of data and functions into a single unit is known as

Explanation ≡ Correct answer: option c) Encapsulation
Encapsulation is the process of wrapping up data (attributes) and functions (methods) into a single unit (class). It allows access to the data only through the methods of the class, providing better control and security over the data.

7. The process by which objects of one class can acquire the attributes of objects of another class is known as

Explanation ≡ Correct answer: option b) Inheritance
Inheritance is the mechanism in object-oriented programming that allows one class to inherit properties (attributes and methods) from another class. This promotes code reuse and the creation of hierarchies of classes, where subclasses inherit characteristics from their parent (super) classes.

8. Which one of the following concepts enables the reusability of code?

Explanation ≡ Correct answer: option c) Inheritance
Inheritance enables the reusability of code by allowing one class to inherit the properties and behaviors of another class. Subclasses can extend and modify the functionality of their parent classes while reusing the code implemented in the parent class.

9. The term function overloading refers to:

Explanation ≡ Correct answer: option d) Polymorphism
Function overloading is a form of polymorphism where multiple functions with the same name but different parameters (either in number or type) can coexist in a class. The appropriate function to be called is determined based on the number and types of arguments provided during the function call.

10. Which of the following characteristics C++ does not support?

Explanation ≡ Correct answer: option c) Garbage collection
  1. Persistence is the ability of an object to retain its state even after the program that created it terminates. C++ supports persistence through the use of serialization.
  2. Generacity is the ability to create objects of a generic type. C++ supports generacity through the use of templates.
  3. Late binding is the ability to defer the binding of a method call to a specific implementation until runtime. C++ supports late binding through the use of virtual functions.
  4. Garbage collection is the automatic management of memory allocation and deallocation. C++ does not support garbage collection.

11. Encapsulation ensures that

Explanation ≡ Correct answer: option b) External functions cannot access an object’s nonpublic data.
Encapsulation in object-oriented programming restricts the access to an object's internal data, allowing only the methods (functions) of the class to manipulate the data. This ensures data security and prevents external functions or code from directly modifying the object's nonpublic data.

12. A rectangle notation that is used to denote an object usually show

Explanation ≡ Correct answer: option c) Data and functions of the object
In UML (Unified Modeling Language) notation, a rectangle represents a class or an object. It typically shows the data members (attributes) and member functions (methods) of the object, providing a concise overview of the object's structure and behavior.


Your Score is 10

THE STUDENT FRIENDLY BOOK TO LEARN C++. 
Let us C++ by Famous author Yashavant Kanetkar
Indian writer


Topic wise C++ MCQs Index ≡ (Click to open)
Click on particular topic to visit that page
  1. Principles of Object-Oriented Programming 
  2. Beginning with C++
  3. Tokens, Expressions, and Control Structures
  4. Functions in C++
  5. Classes and Objects
  6. Constructors and Destructors
  7. Operator Overloading
  8. Inheritance
  9. Pointers, Virtual Functions, and Polymorphism
  10. Managing Console I/O Operations
  11. Working with Files
  12. Templates
  13. Exception Handling
  14. Standard Template Library
  15. Manipulating Strings
  16. New Features in ANSI C++ Standards
  17. Object-Oriented System Development

Post a Comment

0 Comments