Which of the following is **not** a pillar of Object-Oriented Programming in C++?
Analysis & Theory
`Compilation` is not an OOP concept. The four main pillars of OOP are: Encapsulation, Inheritance, Abstraction, and Polymorphism.
What does **encapsulation** mean in C++?
A
Hiding the data and implementation details inside a class
B
Using multiple inheritance
C
Using private variables only
D
Defining many functions with the same name
Analysis & Theory
Encapsulation means bundling data and functions together and restricting direct access to some components using access specifiers.
Which keyword is used to inherit from a class in C++?
Analysis & Theory
C++ uses a colon (:) to indicate inheritance: `class B : public A`.
What is **polymorphism** in C++?
A
Same function name behaving differently based on input
B
Ability to write code once and use it many times
C
The process of hiding the implementation
D
Accessing variables from other classes
Analysis & Theory
Polymorphism allows the same function or method to behave differently depending on the context (compile-time or run-time).
Which of the following enables **runtime polymorphism**?
Analysis & Theory
Runtime polymorphism in C++ is achieved using **virtual functions** and **base class pointers/references**.
Which access specifier allows access within the same class only?
Analysis & Theory
`private` members are accessible only within the same class.
Which concept allows one class to inherit features from another?
Analysis & Theory
Inheritance allows one class to derive or inherit properties and behaviors from another.
Which feature of OOP binds code and data together?
Analysis & Theory
Encapsulation binds data and functions that operate on that data together into a single unit (class).
What is a class in C++?
A
A group of unrelated functions
B
A blueprint for creating objects
D
A method to store variables globally
Analysis & Theory
A class is a **blueprint** or template for creating objects that share attributes and behaviors.
Which of the following best defines an **object** in OOP?
Analysis & Theory
An object is an instance of a class, created to use the data and methods defined in the class.