Which of these is NOT a benefit of using functions in programming?
Easier debugging and maintenance
Improved code organization
Increased memory usage
Code reusability
Which statement is used to display output to the console in C++?
cin
printf
cout
print
What is the concept of abstraction in OOP?
Hiding complex implementation details and exposing only essential information
Using virtual functions for polymorphism
Creating objects from a class
Implementing multiple inheritance
What is the correct way to receive user input in C++ and store it in a variable named 'name'?
cout << name;
scanf name;
cin >> name;
input name;
What is the primary purpose of a constructor in a C++ class?
To implement polymorphism
To initialize object members when an object is created
To free up memory when an object is destroyed
To define the class's interface
What is a potential danger of using pointers incorrectly?
It can make the code harder to debug due to the indirect way of accessing data.
It can cause segmentation faults if a pointer is dereferenced without a valid memory address.
All of the above
It can lead to memory leaks if allocated memory is not freed.
What is the correct way to declare a constant variable named 'PI' with the value 3.14159?
#define PI = 3.14159
constant PI = 3.14159;
const float PI 3.14159;
const float PI = 3.14159;
How can you prevent a C++ class from being inherited from?
By using the 'abstract' keyword
By declaring it with the 'final' keyword
By making all its members private
By not defining any constructors
What is a pure virtual function in C++?
A function that can be called before an object is created
A function that creates new data types
A function that automatically destroys an object
A function with no implementation in the base class, meant to be overridden by derived classes
Which operator is used to access members of an object using a pointer to that object?
->
::
.