Which statement is used to display output to the console in C++?
cout
cin
print
printf
Which keyword is used to achieve inheritance in C++?
inherits
implements
colon (:)
extends
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 previous element in the array
The address of the array itself
Which principle of OOP emphasizes hiding internal details and exposing only essential information?
Polymorphism
Abstraction
Inheritance
Encapsulation
What is the output of the following code snippet?
int i = 10; do { cout << i << " "; i--; } while (i > 10);
The loop will run infinitely
10
9 8 7 6 5 4 3 2 1 0
10 9 8 7 6 5 4 3 2 1
Which of the following is NOT a valid C++ function definition?
double calculateArea(double radius) { return 3.14 * radius * radius; }
int sum(int a, int b) { return a + b; }
void printMessage();
string greet(string name) { cout << "Hello, " << name << "!" << endl; }
What does the 'protected' access specifier in C++ control?
Accessibility only within the same file
Accessibility within the same class only
Accessibility within the same class and derived classes
Accessibility from anywhere in the program
What is the concept of abstraction in OOP?
Using virtual functions for polymorphism
Creating objects from a class
Implementing multiple inheritance
Hiding complex implementation details and exposing only essential information
int arr[] = {10, 20, 30}; int *ptr = arr; cout << *(ptr + 2);
Invalid memory access
30
20
Which operator is used to combine two strings in C++?
/