C++ Test
C++ Test
C++ Test
NAME - MM – 25
CLASS - OBT –
2. Which of the following is the correct way to initialize an integer variable named "x" with the value
10?
#include <iostream>
int main() {
int x = 5;
int y = x++;
return 0;
a) 4 b) 5 c) 6 d) Compiler error
5. What is the correct way to define a function named "add" that takes two integer parameters and
returns their sum?
a) It terminates the program execution. b) It skips the current iteration of the loop.
#include <iostream>
int main() {
return 0;
a) 1 b) 2 c) 3 d) 4
8. What is the correct way to dynamically allocate memory for an integer variable in C++?
a) The variable can be accessed from any part of the program. b) The variable can be accessed only
within the function where it is declared.
c) The variable can be accessed within the file where it is declared. d) The variable can be accessed
only within the class where it is declared.
11. Which of the following is the correct syntax to add the header file in the C++ program?
A.Distributed B.Multiple
C.Multi-level D.Hierarchal
1)X,Y->Z 2)X->Y->Z
15) Which of the following options correctly explains the concept of Polymorphism?
a. int func(float); float func(int, int, char); b.int func(int); int func(int);
a) VAR_1234 b) $var_name
c) 7VARNAME d) 7var_name
18) Which of the following is used to terminate the function declaration in C++?
a) ; b) ] c) ) d) :
19) For inserting a new line in C++ program, which one of the following statements can be used?
a)An array is a set of similar data items b)An array is a set of distinct data items
c)An array can hold different types of datatypes d)None of the above
21) If we stored five elements or data items in an array, what will be the index address or the index
number of the array's last data item?
22) Which of the following statements is correct about the friend function in C++ programming
language?
23) More than one user-defined function can have the same name and perform different operations.
This feature of c++ is known as ___.
a) Function overloading b) operator overloading
c) overloading d) None of these
24) ___ member function invoked automatically whenever the objects are destroyed or expired
a) destructor ~ b) constructor c) polymorphism d)dynamic binding
25)