ExamVeda
Login
Home
21
What does the 'static' keyword mean when used with a global variable in C++?
Discuss
Answer & Solution
Answer: Option A
Solution:
Reason: In C++, when the 'static' keyword is used with a global variable, it limits the scope of that variable to the file in which it is declared.

Option A: Scope limited to the file is correct because a global variable declared as static can only be accessed within the file where it is defined, making it invisible to other files in the program.

Option B: Can't be modified is incorrect because the 'static' keyword does not make the variable constant or immutable. It can still be modified.

Option C: Retains its value between calls applies to local static variables, not global static variables. Global static variables are not related to function calls.

Option D: Global scope is incorrect because the 'static' keyword specifically restricts the scope of the variable to the file, contrary to the global scope.

Hence, the correct interpretation of 'static' for global variables is that it limits the scope to the file where the variable is declared.
22
Which of the following is used to access the first element of an array in C++?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
23
What is the output of the following code: cout << (5 == 5.0); in C++?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
24
What is the purpose of the 'break' statement in a switch-case construct in C++?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
25
What is the correct way to include a C++ standard library header file named 'vector' in a C++ program?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
26
Which operator is used to access the member functions and variables of an object in C++?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
27
What is the output of the following code: cout << (10 / 4); in C++?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
28
What is the correct syntax to define a function named 'add' that takes two integers as parameters and returns their sum in C++?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
29
Which of the following is not a valid data type in C++?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
30
What does the 'new' operator return when memory allocation fails in C++?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board