Which of the following is NOT a type of inheritance in C++?
Multilevel inheritance
Distributed inheritance
Multiple inheritance
Single inheritance
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
9 8 7 6 5 4 3 2 1 0
10
Which data type is used to store whole numbers without any decimal points?
float
double
string
int
What is the output of the following C++ code snippet?
#include <iostream> int main() { int arr[5] = {10, 20, 30, 40, 50}; std::cout << arr[3]; return 0; }
30
40
50
int x = 5; if (x > 10) { x = 10; } else if (x < 0) { x = 0; } cout << x;
0
None of the above
5
Which keyword is used to achieve inheritance in C++?
colon (:)
extends
implements
inherits
How do you declare a multi-dimensional array (specifically, a 2D array) in C++?
array matrix[3, 4];
int matrix[3, 4];
int matrix[3][4];
int matrix(3)(4);
Which operator is used to access members of an object using a pointer to that object?
.
->
::
In a switch-case statement, what happens if no case matches the switch expression and there is no 'default' case?
A compilation error occurs.
The behavior is undefined.
The program enters an infinite loop.
The switch-case statement is skipped.
What is a potential danger of using pointers incorrectly?
All of the above
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.
It can lead to memory leaks if allocated memory is not freed.