What does the 'protected' access specifier in C++ control?
Accessibility within the same class only
Accessibility from anywhere in the program
Accessibility within the same class and derived classes
Accessibility only within the same file
Can a function in C++ return multiple values?
Yes, using multiple 'return' statements.
Yes, by using references or pointers as parameters.
No, a C++ function can only return a single value.
Yes, by returning a container like a vector or an array.
Which principle of OOP emphasizes hiding internal details and exposing only essential information?
Abstraction
Polymorphism
Inheritance
Encapsulation
Which operator is used to combine two strings in C++?
/
What is a function signature in C++?
The comments and documentation associated with a function.
The function's body (the code within the curly braces).
The value returned by the function.
The function's name and the data types of its parameters.
If 'func' is a function that takes an integer and returns void, how would you call this function using a pointer 'ptr' to the function?
ptr(5);
&ptr(5);
*ptr(5);
func(ptr, 5);
What is the value of 'i' after the following loop completes?
int i; for (i = 0; i < 5; i++) { // Loop body }
Undefined behavior
6
4
5
Which of the following is NOT a valid way to initialize a character array in C++?
char message[10] = {'H', 'e', 'l', 'l', 'o'};
char message[] = "Hello";
char message[5] = "Hello";
char message[10] = "Hello";
Which of the following accesses the third element of an integer array named 'data'?
data[3]
data.third
data[2]
data.2
What is the output of the following code snippet: cout << (5 > 3 && 10 < 20);?
cout << (5 > 3 && 10 < 20);
3
1
0