In a switch-case statement, what happens if no case matches the switch expression and there is no 'default' case?
The behavior is undefined.
A compilation error occurs.
The switch-case statement is skipped.
The program enters an infinite loop.
Which of the following is NOT a valid way to initialize a character array in C++?
char message[10] = "Hello";
char message[] = "Hello";
char message[5] = "Hello";
char message[10] = {'H', 'e', 'l', 'l', 'o'};
What is the correct syntax to declare a pointer variable named 'ptr' that points to an integer?
ptr int;
int &ptr;
int *ptr;
*int ptr;
What is the output of the following C++ code snippet?
#include <iostream> int main() { int x = 5; int y = 10; int result = (x, y); std::cout << result; return 0; }
Compilation Error
10
15
5
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.
What is the value of 'i' after the following loop completes?
int i; for (i = 0; i < 5; i++) { // Loop body }
6
4
Undefined behavior
What is a potential danger of using pointers incorrectly?
It can lead to memory leaks if allocated memory is not freed.
It can cause segmentation faults if a pointer is dereferenced without a valid memory address.
It can make the code harder to debug due to the indirect way of accessing data.
All of the above
Which keyword is used to achieve inheritance in C++?
colon (:)
inherits
extends
implements
int x = 5; if (x > 10) { x = 10; } else if (x < 0) { x = 0; } cout << x;
0
None of the above