What is the purpose of the 'return' statement in a C++ function?
It marks a section of code for debugging purposes.
It prints the function's output to the console.
It terminates the function's execution and returns control to the calling function.
It declares a new variable within the function.
Which C++ library provides functions for string manipulation, such as copying, concatenation, and comparison?
#include <array>
#include <cstring>
#include <iostream>
#include <string>
How do you declare a variable named 'age' of integer type?
age as int;
declare age as integer;
variable age: int;
int age;
What is the value of 'i' after the following loop completes?
int i; for (i = 0; i < 5; i++) { // Loop body }
6
5
Undefined behavior
4
Which keyword is used to achieve inheritance in C++?
colon (:)
inherits
extends
implements
Which of the following is NOT a valid way to initialize a character array in C++?
char message[] = "Hello";
char message[10] = "Hello";
char message[10] = {'H', 'e', 'l', 'l', 'o'};
char message[5] = "Hello";
Which principle of OOP emphasizes hiding internal details and exposing only essential information?
Abstraction
Encapsulation
Inheritance
Polymorphism
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 does the modulus operator (%) return?
The remainder of a division.
The product of two operands.
The sum of two operands.
The quotient of a division.
What is the correct way to declare an integer array named 'numbers' with a size of 5 in C++?
int numbers(5);
array numbers[5];
numbers[5] as int;
int numbers[5];