Which of the following is NOT a valid C++ function definition?
int sum(int a, int b) { return a + b; }
string greet(string name) { cout << "Hello, " << name << "!" << endl; }
void printMessage();
double calculateArea(double radius) { return 3.14 * radius * radius; }
What is the concept of abstraction in OOP?
Hiding complex implementation details and exposing only essential information
Implementing multiple inheritance
Using virtual functions for polymorphism
Creating objects from a class
Which keyword is used to achieve inheritance in C++?
inherits
implements
colon (:)
extends
In C++, a character array can be used to store a string. What is the special character that signifies the end of a string in a character array?
.
'\0'
\n
\0
What is the output of the following C++ code snippet?
int x = 5; if (x > 10) { x = 10; } else if (x < 0) { x = 0; } cout << x;
0
5
10
None of the above
If 'ptr' points to the first element of an array, what does 'ptr + 1' point to?
The next element in the array
The size of the array
The address of the array itself
The previous element in the array
What is the purpose of the 'break' statement in a switch-case statement?
To exit the switch-case statement
To skip to the next case statement
To jump to a specific case statement
To repeat the current case statement
What is the correct way to declare an integer array named 'numbers' with a size of 5 in C++?
array numbers[5];
int numbers(5);
numbers[5] as int;
int numbers[5];
What is the correct syntax to declare a pointer variable named 'ptr' that points to an integer?
int *ptr;
*int ptr;
ptr int;
int &ptr;
Which operator is used to combine two strings in C++?
/