1What is the main difference between procedural programming and object-oriented programming?
Procedural programming focuses on functions and data, while object-oriented programming focuses on objects containing both data and functions.
2What is the DRY principle in programming?
The DRY (Don't Repeat Yourself) principle is about reducing code repetition by extracting common code and reusing it.
3What is a class in C++?
A class is a template for objects, defining attributes and methods that can be inherited by objects.
4What is an object in C++?
An object is an instance of a class that can access its attributes and methods.
5What are attributes and methods in a class?
Attributes are variables, and methods are functions that belong to a class.
6What is encapsulation in OOP?
Encapsulation is the process of wrapping data and functions together in a single unit and hiding the details from outside access.
7What is abstraction in OOP?
Abstraction is the concept of displaying only essential information and hiding the background details or implementation.
8What is polymorphism in C++?
Polymorphism is the ability of a function or operator to have multiple forms, such as function overloading and operator overloading.
9What is operator overloading in C++?
Operator overloading is the process of making an operator behave differently based on the type or number of operands.
10What is function overloading in C++?
Function overloading allows multiple functions to have the same name but with different parameters.
11What is inheritance in OOP?
Inheritance is the capability of one class (subclass) to derive properties and behaviors from another class (superclass).
12What is the benefit of inheritance in OOP?
Inheritance supports reusability, allowing new classes to reuse code from existing classes.
13What are access specifiers in C++?
Access specifiers (public, private, protected) define the visibility of class members from outside the class.
14What is an example of abstraction in C++?
An example of abstraction is using header files like math.h, where functions like pow() are used without knowing their internal algorithm.
15What is the purpose of a constructor in a class?
A constructor is used to initialize the variables of a class when an object is created.