
Q31
Q31 What is an array in C++?
A collection of variables of different types
A single variable that can store multiple values
A function that returns multiple values
A data structure that allows recursion
Q32
Q32 How do you access the third element in an array named 'arr' in C++?
arr[2]
arr[3]
arr(2)
arr(3)
Q33
Q33 What are multidimensional arrays in C++?
Arrays with only one row or column
Arrays with more than one dimension, like 2D or 3D arrays
Arrays containing elements of different data types
Dynamic arrays
Q34
Q34 What is the size of a character array initialized as char arr[] = "Hello";?
4
5
6
7
Q35
Q35 Pseudocode:
SET arr[3] TO [10, 20, 30] PRINT arr[0] What does this print?
10
20
30
0
Q36
Q36 Pseudocode:
SET nums[5] TO [1, 2, 3, 4, 5] FOR EACH num IN nums DO PRINT num What does this print?
12345
54321
15
Error
Q37
Q37 Pseudocode:
SET arr[3] TO [0] FOR i FROM 0 TO 2 DO SET arr[i] TO i + 1 END PRINT arr[2] What is the output?
1
2
3
0
Q38
Q38 Spot the mistake:
int nums[] = {1, 2, 3};
for(int i = 0; i <= 3; i++) {
cout << nums[i];
}
Incorrect loop condition
Missing array initialization
No error
Syntax error in cout statement
Q39
Q39 Find the error in this code:
char str[5]; str = "Hello";
cout << str;
Invalid assignment to char array
No error
Syntax error in cout statement
Array size mismatch
Q40
Q40 What is a pointer in C++?
A variable that stores the address of another variable
A reference to another variable
A type of array
A function parameter
Q41
Q41 What is the purpose of the reference operator (&) in C++?
To create a reference variable
To access the address of a variable
To dereference a pointer
To perform bitwise AND
Q42
Q42 How are arrays and pointers related in C++?
Pointers can only point to the first element of an array
Arrays and pointers are fundamentally different
An array name can be used as a pointer to its first element
Pointers cannot be used to access array elements
Q43
Q43 Given the code
int arr[] = {1, 2, 3};
int *ptr = arr;
cout << ptr[1];,
what is the output?
1
2
3
&arr[1]
Q44
Q44 Pseudocode:
SET arr TO [10, 20, 30] SET ptr TO ADDRESS OF arr[0] PRINT ptr[2] What is the output?
10
20
30
ADDRESS OF arr[2]
Q45
Q45 Find the mistake:
int num = 10;
int &ref = num;
ref = nullptr;
cout << num;
Assigning nullptr to a reference
Syntax error
No error
Incorrect initialization of the reference
Q46
Q46 What is inheritance in OOP?
The process of acquiring properties from one class to another
Copying of methods between classes
Linking of two classes
Creating new classes
Q47
Q47 What does encapsulation in C++ refer to?
The process of combining data and functions into a single unit
Creating multiple copies of the same function
Protecting data by making it private
Linking different classes together
Q48
Q48 In C++, what is polymorphism?
The ability of different classes to have methods with the same name
The capability of a class to have multiple constructors
The ability of a function to perform different tasks based on the context
The concept of creating many objects from a single class
Q49
Q49 What is operator overloading in C++?
Giving additional meaning to C++ operators
Creating new operators in C++
Using existing operators in different contexts
Defining operators only in classes
Q50
Q50 What is the output of this C++ code?
class Test {
public:
int x;
}; Test obj;
obj.x = 5;
cout << obj.x;
5
0
Error
Undefined
Q51
Q51 In the code class Base {
};
class Derived : public Base {
};,
which OOP concept is illustrated?
Encapsulation
Polymorphism
Inheritance
Abstraction
Q52
Q52 Pseudocode:
CLASS Animal FUNCTION makeSound() PRINT "Sound" What is this an example of?
A function in C++
A class in C++
Polymorphism in C++
Encapsulation in C++
Q53
Q53 Pseudocode: CLASS Bird EXTENDS Animal FUNCTION makeSound() PRINT "Chirp" What concept is shown here?
Inheritance
Polymorphism
Encapsulation
Abstraction
Q54
Q54 Find the error:
class MyClass { public: MyClass(int x) {
cout << x; }
};
MyClass obj;
Missing default constructor in class definition
Syntax error
No error
Incorrect constructor usage
Q55
Q55 Spot the error:
class Test {
public:
int x;
void Test() {
x = 0; }
};
Incorrect constructor syntax
No error
Syntax error in variable declaration
Member initialization error
Q56
Q56 In C++, which function is used to open a file?
file.open()
file.read()
file.write()
file.close()
Q57
Q57 What is a file pointer in C++?
A pointer to the contents of a file
A variable that stores the memory address of a file
A marker that keeps track of the file's current read/write position
A pointer to the file's metadata
Q58
Q58 How do you move the file pointer to a specific location for reading or writing in a file in C++?
Using the move() function
Using the relocate() function
Using the seekg() and seekp() functions
Using the transfer() function
Q59
Q59 Identify the issue in this C++ code:
ifstream file;
file.open("data.txt");
Incorrect file mode
File not closed
Missing file path
No error
Q60
Q60 What is the purpose of the new operator in C++?
To create a new class
To allocate memory on the stack
To allocate memory on the heap
To define a new data type


