MCQ Based on Basics of C++ 1) #include<userdefined.h> Which of the following is the correct syntax to add the header file in the C++ program? a. #include<userdefined> b. #include "userdefined.h" c. <include> "userdefined.h" d. Both A and B Answer: D Explanation: To include the herder files in the C++ program user can use any of the following given syntax. 1. #include <Filename.h> or 1. #include "filename.h" 2) Which of the following is the correct syntax to print the message in C++ language? A. cout <<"Hello world!"; B. Cout << Hello world! ; C. Out <<"Hello world!; D. None of the above Answer: A Explanation: To print the message in the C++ language user can use the following syntax: 1. #include <iostream> 2. using namespace std; 3. 4. int main() { 5. cout << "Hello World!"; 6. cout << "I am learning C++"; 7. return 0; 8. } 9. 3) Which of the following is the correct identifier? A. $var_name ,special character not allowed B. VAR_123 C. varname@ D. None of the above 4) Which of the following is the address operator? A. @ B. # C. & D. % ,,, Answer: C Explanation: To print the address of any variable, a user can use the "&" operator. To understand it more clearly, consider the following example: 1. #include <iostream> 2. #include<conio.h> 3. using namespace std; 4. int main() { 5. // Declare Variables 6. int a; 7. int *pt; 8. cout << "C++ Pointer Example Program : Print Pointer Address\n"; 9. a = 10; 10. pt = &a; 11. cout << "\n[a ]: Value of A = " << a; 12. cout << "\n[*pt]: Value of A = " << *pt; 13. cout << "\n[&a ]: Address of A = " << &a; 14. cout << "\n[pt ]: Address of A = " << pt; 15. cout << "\n[&pt]:Address of pt = " << &pt; 16. cout << "\n[pt ]:Value of pt = " << pt; 17. getch(); 18. return 0; 19. } 5) Which of the following features must be supported by any programming language to become a pure object-oriented programming language? A. Encapsulation,, Encapsulation is an oop concept B. Inheritance,, Inheritance is an oop concept C. Polymorphism D. All of the above Answer: D Explanation: There is nothing that forces a user to use the OOP concept in C++. In contrast, it is necessary for a programming language that it must support all three features as encapsulation, inheritance, and polymorphism completely to become a pure Object-Oriented Language. 6) The programming language that has the ability to create new data types is called___. A. Overloaded B. Encapsulated C. Reprehensible D. Extensible Answer: D Explanation: A language that can generate the new data types is known as the extensible languages as they can handle the new data types. 7) Which of the following is the original creator of the C++ language? A. Dennis Ritchie B. Ken Thompson C. Bjarne Stroustrup D. Brian Kernighan Answer: C Explanation: Bjarne Stroustrup creates C++ language during 1997 at AT&T Bell Labs. 8) Which of the following is the correct syntax to read the single character to console in the C++ language? A. Read ch() B. Getline vh() C. get(ch) // “ cin.get()” D. Scanf(ch) Answer: C Explanation: The "cin.get()" is one of the several functions provided in C++ language that is used to read the single or multiple characters to console. 9) Which of the following statements is correct about the formal parameters in C++? A. Parameters with which functions are called B. Parameters which are used in the definition of the function C. Variables other than passed parameters in a function D. Variables that are never used in the function Answer: A Explanation: Parameters that are used in the body of the function are known as formal parameters. These parameters represent the parameters passed to the function and are only used inside the function's body. 10) The C++ language is ______ object-oriented language. A. Pure Object oriented B. Not Object oriented C. Semi Object-oriented or Partial Object-oriented D. None of the above Answer: C Explanation: The common thing about the Pure Object-oriented language it provides three basic features like Inheritance, Encapsulation, and Polymorphism. Each programming language that supports these entire three features is known as the Pure-Object oriented language. Whereas if a programming language support all these three features but not support completely are known as the Partial-Object oriented languages or the Semi Objectoriented languages. The main reasons why the C++ programming language is Known as Semi-Object oriented language are as follows: 1. Availability of the Friend function:A friend class is allowed to access private and protected members of another class, within which it is declared a friend. It may be very useful for some time, but still, it violates the rule of the Object-Oriented features. 2. Concept of the Global variable:As we all know that we can declare a global variable in C++ language that can be easily accessible from anywhere within the program. So again, C++ does not provide complete privacy because no one is restricted to access and manipulate that data/information. Hence it offers partial Encapsulation, unlike Java Language, in which a user only allows to declare a variable within the class and can provide access specifier to it. 3. The main function is Out-side the classC++ is an object-oriented language, but still, object-oriented is not fundamentally related (or implicit) to the language. So a user can easily write a valid, well-defined C++ code even without using any object once. 11) Which of the following features is required to be supported by the programming language to become a pure object-oriented programming language? A. Encapsulation B. Inheritance C. Polymorphism D. All of the above Answer: D Explanation: There is nothing that forces a user to use the OOP concept in C++. In contrast, it is necessary for a programming language that it must support all three features of Encapsulation, Inheritance, and Polymorphism completely to become a Pure Object-Oriented Language. 12) Which of the following comment syntax is correct to create a single-line comment in the C++ program? A. //Comment. Single line comment :- // B. /Comment/ C. Comment// D. None of the above Answer: A Explanation: To create a single line comment (or one-line comment) in C++ program one can use the "// write comment" syntax. We can understand it more easily with the help of following given Program: Example 1. #include <stdio.h> 2. int main(void) 3. { 4. // This is a single line comment 5. // Welcome user comment 6. printf("Welcome to Javatpoint"); 7. return 0; 8. } 13) C++ is a ___ type of language. A. High-level Language B. Low-level language C. Middle-level language D. None of the above Answer: C Explanation: C++ contains the features of both types of high and Low-level programming languages, and it is also not wrong if we call it the combination of both high and low-level languages. 14) For inserting a new line in C++ program, which one of the following statements can be used? A. \n B. \r C. \a D. None of the above Answer: A Explanation: To insert a new line or to jump on to the next line, one can use the "\n." In c++, there is also an alternative is available that is "endl," which is also used for breaking a line in the output. Let see the example of both the "\n" and "endl." Example: Using "\n." 1. #include <iostream> 2. using namespace std; 3. 4. int main() { 5. cout << "Hello World! \n\n"; 6. cout << "I am learning C++"; 7. return 0; 8. } Output Hello World! I am learning C++ Example: With using "end" 1. #include <iostream> 2. using namespace std; 3. 4. int main() { 5. cout << "Hello World!" << endl; 6. cout << "I am learning C++"; 7. return 0; Output Hello World! I am learning C++ 15) Which one of the following represents the tab? A. \n B. \t C. \r D. None of the above Answer: B Explanation: The "\t" is a type of space sequence representing the tab, which means a set of blank space adds to the line. To understand it more clearly, consider the following example: Program 1. #include<iostream> 2. using namespace std; 3. int main() 4. { 5. int a,b; 6. cout<<"Enter the first number\t"; 7. cin>>a; 8. cout<<"Enter the second number\t"; 9. cin>>b; 10. if(a>b) 11. cout<<"Greatest number is\t"<<a; 12. else 13. cout<<"Greatest number is\t"<<b; 14. return 0; 15. } Output Enter the first number Enter the second number Greatest number is 12 13 13 1) Which of the following refers to characteristics of an array? 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 Answer: A Explanation: Basically, an array is a set of similar data items that are stored in the contiguous memory blocks. You can access any data item randomly using the index address of the elements. 2) 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? A. 3 B. 5 C. 4 D. 88 Answer: C Explanation: The array uses the contiguous block of memory for storing the data elements. Hence the data items pushed into an array are stored at the continuous address space. The index number of the array begins with zero so, the first data item pushed into the array will be stored at zero and so on. Hence index number of the last (fifth) element will be 4. 3) Which of the following is the correct syntax for declaring the array? A. init array [] B. int array [5]; C. Array[5]; D. None of the above Answer: B Explanation: To declare an array in C++, we first need to specify its data type according to requirements such as int or char, afterward that the array's name and the size of the array. So the correct answer will be B. Example: Array declaration by specifying size and initializing elements int arr[8] = { 10, 20, 30, 40 }; The compiler will create an array of size 8, initializes the first four elements as specified by the user and rest elements as 0 The above is just same as "int arr[] = {11, 22, 32, 44, 0, 0,0,0}". 4) Which of the following is the correct syntax for printing the address of the first element? A. array[0]; B. array[1]; C. array[2]; D. None of the above Answer: A Explanation: To print or access the first data item of the array, the correct syntax is "array[0];" because the array's index begins with zero instead of one. So the correct answer will be A. 5) Which of the following gives the 4th element of the array? A. Array[0]; B. Array[0]; C. Array [3]; the fourth element. D. None of the above Answer: C Explanation: The index of the array begins with zero instead of 1. To print the 4th element of the array, the index number will be n-1 or (3); 6) What is the output of the given program? 1. #include <stdio.h> 2. using namespace std; 3. int main() 4. { 5. int array[] = {10, 20, 30}; 6. cout << -2[array]; 7. return 0; 8. } 9. a. -15 b. -30 c. Compiler error d. Garbage value Answer: B Explanation: It will print the negative value of the specified values because the "-" sign we used while specifying the array elements. So the correct answer will be the "-30". 7) Which type of memory is used by an Array in C++ programming language? A. Contiguous B. None-contiguous C. Both A and B D. Not mentioned Answer: A Explanation: In the C and C++ programming language, the memory used by an array is usually contiguous, which means when an array is declared or initialized in the program a block of memory is selected form the memory space immediately. The major drawback of an array is that users have to guess the size of the array before actually using it, in which a significant amount of memory will be occupied even when it is not used. This later creates the problem of lack of memory. 8) Which of the following is the correct definition of sorting? A. Sorting is a type of process in which the data or information is ordered into a specific order. Example increasing orders, decreasing. B. Sorting information or data only in increasing order C. Sorting is a type of process in which data elements are modified or manipulated D. None of the above Answer: A Explanation: Sorting is a type of technique or process in which the locations of data elements hold by the array are reordered or manipulated. So the correct answer will be A. For Example Un-sorted Array 4 3 2 1 5 6 7 2 3 4 5 6 7 Sorted Array 1 9) How many types of the array are there in the C++ programming language? A. In the C++ programming language, there are three types of arrays B. In the C++ programming language, there are four types of arrays C. In the C++ programming language, there are two types of arrays D. Both A and B Answer: C Explanation: In the C++ programming language, there are mainly two types of arrays that are Single Dimension arrays and Multi-Dimension arrays. In Single-Dimension arrays, the same types of values are hold in the form of a List, while on the other hand, in Multi-Dimension arrays; values are stored in the form of a matrix. 10) In C++, for what purpose the "rank ()" is used? A. It returns the size of each dimension B. It returns the maximum number of elements that can be stored in the array C. It returns the dimension of the specified array D. None of the above Answer: C Explanation: In C++, one can use the rank function where he wants to know about the dimensions (e.g., single-dimension, multi-dimension) of a specific array by just passing it to the "rank ()" function. 11) Which one of the following is the correct definition of the " is array(); " function in C++? A. It checks that the specified variable is of the array or not B. It checks that the specified array of single dimension or not C. It checks that the array specified of multi-dimension or not D. Both B and C Answer: A Explanation: In C++, the "is_array();" is used for checking that the specified element or data item belongs to the array type or not. 12) Observer the given C++ program carefully and choose the correct output from the given options: Program 1. #include <iostream> 2. #include <string> 3. using namespace std; 4. int main() 5. { 6. cout<<is_array<int>::value; // case A 7. cout<<is_array<char[10]>::value; // case B 8. cout<<is_array<string>::value; // case c 9. return 0; 10. } a. 110 b. 001 c. 010 d. None of the above Answer: C Explanation: The correct output will be "010" Because in both cases, A and C variables passed to the "is_array()" function are different, so the function returns zero in both cases while in the case of B, they are the same. Hence it returns one as the output. 13) Read the given C++ program carefully and choose the correct output from the given options: Program 1. #include <iostream> 2. #include <string> 3. using namespace std; 4. int main() 5. { 6. cout<<rank<int[10]>::value; // Case A 7. cout<<rank<char[10][10]>::value; // Case B 8. cout<<rank<string[10][10][10]>::value; //Case C 9. return 0; 10. } a. 121 b. 321 c. 123 d. 010 14) What did we call an array of the one-dimensional array? A. Single Dimensional array B. Multi-Dimensional array C. 2D Array (or 2-Dimensional array) D. Both A and B Answer: C Explanation: An array of one-dimensional array is known as the 2-dimensional array or 2D Array-like. We can understand it more clearly with the help of the following example: Initialization of 2-Dimensional Array 1. int array[2][3]={ {3,2,5} , {9,5,4} } 15) Which types of arrays are always considered as linear arrays? A. Single-dimensional B. Multi-dimensional C. Both A and B D. None of the above Answer: A Explanation: Single-dimensional arrays are always considered as linear arrays. 16) Which of the following can be considered as the object of an array? A. Index of an array B. Elements of the Array C. Functions of the Array D. All of the above Answer: B Explanation: The elements in the array are known as the objects of the array. 17) How many types of elements can an array store? A. Same types of elements B. Char and int type C. Only char types D. All of the above Answer: A Explanation: An array can hold several elements except that all the data elements are of the same type. 18) Elements of a one-dimensional array are numbered as 0,1,2,3,4,5, and so on; these numbers are known as ____ A. Subscript of Array B. Members of Array C. Index values D. Both A and C 1) Which of the following statement is true about the new and malloc? I. The "new" is a type of operator while "malloc" is a kind of function II. "New" invokes a constructor, whereas "malloc" does not invoke the constructor III. "malloc" returns void pointer and also needed to typecast whereas "new" returns required the pointer A. Only I B. Both I and II C. I, II, III D. None of the above Answer: C Explanation: All statements mentioned in the above question are completely true about the "malloc" and the "new." The "malloc" is a kind of function available in the C++ language, while the "new" is a type of operator that invokes the Constructor. 2) Which of the following statement is true about the new and malloc? I. The pointer object initialization of a specific class using "malloc" also needs to include constructor calls; on the other hand, doing so with the "new" keyword does not include any constructor calls. II. The pointer object initialization of a specific class using the "new" keyword also needs to include a constructor call. On the other hand, doing so with the "malloc" does not need to include any constructor calls. III. Pointer object initialization of a specific class using either "new" or "malloc" involves the constructor call. A. Only II B. Both II and III C. Only I D. None of the above Answer: A Explanation: In object initialization of a class using the "new" keyword also involves a constructor call, while doing so with the "malloc" does not require any involvement of the constructor call. This is the main reason why the "new" is added explicitly in the C++ language. However, the "malloc" function is used to assign the memory to any specific pointer, so it assigns an equal amount of memory to the class size. At the same time, the "new" keyword involves the initialization, hence invokes the Constructor of that particular class. 3) Which of the following statement is correct about Virtual Inheritance? A. It is a technique to ensure that a private member of a base class can be accessed B. It is a technique to optimize the multiple inheritances C. It is a technique to avoid the multiple inheritances of the classes D. It is a C++ technique to avoid multiple copies of the base class into the derived or child classes Answer: D Explanation: 4) Which one of the following statements correctly refers to the Delete and Delete [] in C++ programming language? A. Delete is syntactically correct although, if the Delete [] is used, it will obtain an error. a. The "Delete" is used for deleting the standard objects, while on the other hand, the "Delete[]" is used to delete the pointer objects b. The "Delete" is a type of keyword, whereas the "Delete[]" is a type of identifier c. The "Delete" is used for deleting a single standard object, whereas the "Delete[]" is used for deleting an array of the multiple objects Hide Answer Workspace Answer: D Explanation: The "Delete" is used with the single general object, while on the other hand, the "Delete []" is used with the array of the multiple objects initiated with the new operator. 5) Consider the following given program and choose the most appropriate output from the given options: 1. #include <iostream> 2. using namespace std; 3. class A{ 4. public: 5. A(){ 6. cout<<"Constructor called\n"; 7. } 8. ~A(){ 9. cout<<"Destructor called\n"; 10. } 11. }; 12. int main(int argc, char const *argv[]) 13. { 14. A *a = new A[5]; 15. delete[] a; 16. return 0; 17. } a. Segmentation failure. b. Error. c. The Constructor will be invoked five times, and after that destructor will be invoked only once. d. The Constructor will be invoked five times, and after that destructor will also be invoked five times. Show Answer Workspace 6) Consider the following given program and choose the most appropriate output from the given options: 1. #include<iostream> 2. using namespace std; 3. class Base { 4. public: 5. Base() 6. { cout<<"Constructing Base \n"; } 7. ~Base() 8. { cout<<"Destructing Base \n"; } 9. }; 10. class Derived: public Base { 11. public: 12. Derived() 13. { cout<<"Constructing Derived \n"; } 14. ~Derived() 15. { cout<<"Destructing Derived \n"; } 16. }; 17. 18. int main(void) 19. { 20. Derived *d = new Derived(); 21. Base *b = d; 22. delete b; 23. return 0; 24. } a. Constructing base, Constructing Derived, Destructing Base, Destructing Derived b. Constructing base, Constructing Derived, Destructing Base c. Constructing base, Constructing Derived, Destructing Derived, Destructing Base d. None of the above 7) Which of the following can be considered as the correct syntax for declaring an array of pointers of integers that has a size of 10 in C++? A. int arr = new int[10]; B. int *arr = new int*[10] C. int **arr = new int*[10]; D. int *arr = new int[10]; 8) Which of the following can be considered as the members that can be inherited but not accessible in any class? A. Public B. Protected C. Private D. Both A and C Answer: C Explanation: The "Private" member of a class can be inherited by the child class. Still, the child class cannot access them (Or we can say that they are not accessible from the child class). 9) Which of the following can be used to create an abstract class in the C++ programming language? a. By using the pure virtual function in the class b. By declaring a virtual function in the base class c. By declaring the virtual keyword afterward, the class Declaration d. None of the above Hide Answer Workspace Answer: A Explanation: A class must contain at least one declaration of the pure virtual function in itself to be called an abstract class. Therefore to make an abstract class, one has to declare at least one pure virtual function in that class. 10) Which of the following statements is correct about the class? a. An object is an instance of its class b. A class is an instance of its object c. An object is the instance of the data type of that class d. Both A and C Hide Answer Workspace Answer: A Explanation: Generally, an object is an instance of a class, e.g., an object represents the class. 11) Which of the following statements is correct about the friend function in C++ programming language? A. A friend function is able to access private members of a class B. A friend function can access the private members of a class C. A friend function is able to access the public members of a class D. All of the above Answer: D Explanation: A friend function can access any member of a class without caring about the type of member it contains, such as public, private, and protected. 12) Which of the following statement is not true about C++? A. Members of a class are public by default B. A class cannot have the private members C. A structure can have the member functions D. All of the above Answer: C Explanation: In C, structures are not allowed to have member functions; while on the other hand, C++ allows the structure to have the member functions. Members of the class are generally private by default, and those of the structures are public. So it is a completely false statement that classes cannot private members. 13) Which of the following given statement is completely true? I. In an object-oriented programming language, all the function calls are resolved at compile-time. II. In a procedure programming language, all the function calls are resolved at compiletime A. Only II B. Only I C. Both I & II D. None of the above Answer: B Explanation: In a procedure programming language such as C, we do not have the concept of Polymorphism, so all function calls are resolved at the compile-time while, on the other hand, In an Object-Oriented language, through the concept of Polymorphism, all function calls cannot be resolved at the compile-time. 14) Which one of the following cannot be used with the virtual keyword? A. Constructor B. Destructor C. Member function D. None of the above Answer: A Explanation: In C++, we cannot use the virtual keyword with the Constructor because constructors are generally defined to initialize the object of a specific class; hence no other class requires the other class's object. 15) Which of the following is used for implementing the late binding? A. Operator Functions B. Constant Functions C. Virtual Functions D. Both A and B Answer: C Explanation: A virtual function can be used for implementing the concept of late binding. For example - Binding the actual functions to their corresponding calls. 16) Which of the following statements supports that reusable code should be one of the desirable features of any language? A. It helps in reducing the maintenance cost B. It helps in reducing the testing time C. It helps in reducing both the maintenance time and testing time D. It helps in reducing the compile time Answer: C Explanation: While reusing the existing code, we are not required to test/check that code, again and again, because it was already tested while it was written for the very first time. So the reusing the code defiantly helps in reducing the maintenance and testing time. While reusing the existing code, the compile-time most likely to be increased or remain the same, and it is obvious because we use the existing code in our program to save our time( or to include any specific functionality) by which the size of the overall program gets grows which is natural. 50) Which of the following statement is correct about the C++ programming language A. In C++, both the Static and Dynamic type checking are allowed B. In C++, member function are allowed to be of the type canst C. In C++, Dynamic checking is allowed D. None of the above Answer: A Explanation: In C++, both types of static and dynamic checking are allowed. 18) Which of the following is not a kind of inheritance? A. Distributed B. Multiple C. Multi-level D. Hierarchal Answer: A Explanation: Among the above options, Distributed is only, which is not a type of inheritance, while Multiple, Multi-level, and the Hierarchal are the types of inheritance. 19) What will happen if "In a C++ program a class has no name"? A. It is not even allowed in C++ B. It will not have the Constructor C. It will not have the destructor D. Both B and C Answer: C Explanation: In the C++ program, if we use a class without assigning a name. As a result, it will not be going to have a destructor, but it will have the object. To understand it in more detail, consider the following program: Program #include using namespace std; class { public: void func() { cout<<"Hello world"; } }a; int main(int argc, char const *argv[]) { a.func(); return 0; } 20) Which type of approach is used by the C++ language? A. Right to left B. Left to right C. Top to bottom D. Bottom-up Answer: D Explanation: Generally, C++ uses the Bottom-up approach while other programming languages like C use the top-down approach. 21) Which of the following concept refers to adding new components to the program at the run time? A. Dynamic Loading B. Dynamic binding C. Data hiding D. Both A & B Answer: C Explanation: The dynamic loading is referred to as the concept of adding a new component to the program as it runs. 22) How can one implement the compile-time Polymorphism in the C++ programming language? A. By using the Template // polymorphism in C++ B. By using the concepts of inheritance C. By using both the virtual functions and inheritance D. By using only the virtual functions Answer: A Explanation: One can easily implement the Compile-time Polymorphism using the Template. 23) How can one implement the run-time Polymorphism in the C++ programming language? A. By using the Template B. By using the concepts of inheritance C. By using both the virtual functions and inheritance D. By using only the virtual functions Explanation: One can easily implement the Compile-time Polymorphism using the Template. 24) Which of the following offers a programmer the facility of using a specific class object into other classes? A. Polymorphism B. Abstraction C. Inheritance D. Composition Answer: D Explanation: The composition is referred to as the concept of using objects of a specific class into several other classes. 25) Which one of the following cannot be a friend in C++ languages? A. Class B. A Function C. An Object D. None of the above Answer: C Explanation: In general, an object of any class cannot be a friend of the same and any other class as well. However, there are some functions, operator, and classes which can be made a friend. 26) How are the references different from the pointer? A. reference cannot be modified once it initialized B. There is no need of an extra operator for dereferencing of a reference C. A reference cannot be NULL D. All of the above Answer: D Explanation: These are some basic reasons why the references are far different from the pointers. In the case of pointers "*" operator is required for dereferencing the value contain by it. However, the reference does not need any type of operator for deference. A Reference cannot be modified once it is initialized, but it is possible to do so in the case of a pointer. A pointer can be made Null, whereas a reference cannot be NULL. 27) Among the following given options, which can be considered as a member of a class? A. Class variable B. Member variable C. Class functions D. Both A and B Answer: B Explanation: Generally, the functions of any class are also considered as the member function of that class. 28) Which of the following refers to the wrapping of data and its functionality into a single individual entity? A. Modularity B. Abstraction C. Encapsulation D. None of the above 29) Which of the following refers to using the existing code instead of rewriting it? A. Inheritance B. Encapsulation C. Abstraction D. Both A and B Answer: A Explanation: With the help of the inheritance concept, one can use existing code instead of rewriting. We can do this by inheriting the properties of pre-written code in other parts of the code blocks. Therefore the user is not required to write the same code repeatedly. 30) Among the following, which shows the Multiple inheritances? A. X,Y->Z B. X->Y->Z C. X->Y;X->Z D. None of the above Answer: A Explanation: In multiple inheritances, a single class can inherit properties form more than one base class. 31) Which of the following statements is true about the C++ programming language? A. C++ is an object-oriented programming language B. C++ is a procedural programming language C. C++ is a functional programming language D. C++ is both procedural and object-oriented language 32) Among the following, which statement is correct about the Modularity? a. Modularity means hiding the parts of the program b. Modularity refers to dividing a program into subsequent small modules or independent parts c. It refers to overloading the program's part d. Modularity refers to wrapping the data and its functionality into a single entity Answer: B Explanation: Modularity refers to dividing a program into small independent code blocks or modules so that they can be easily called anywhere in the entire program where it is required. The concept of Modularity is very efficient and helpful for developers because it makes the program well-structured and easy to understand. Hence the correct option is D. 33) Read the following program carefully and find out which concept from the given options is not used or missing in the following program? Program 1. class A 2. { 3. int x; 4. public: 5. void print(){cout<<"hello"<<x;} 6. } 7. class B: public A 8. { 9. int y; 10. public: 11. void assign(int a){y = a;} 12. } a. Polymorphism b. Encapsulation c. Inheritance d. Abstraction Answer: A Explanation: As we can see in the above-given program, the variables X and Y both are private members, which means they both are hidden from the outside world of the class, so here the concept of abstraction is used. The other data members and their corresponding functions are stored in an individual class, so here the concept of Encapsulation is also used. In addition, Class B is derived from Class A, which means the concept of inheritance is used as well, but still, we didn't find and an overloaded function in any of the classes. Therefore the concept of Polymorphism is missing or not used in the given program. 34) Which of the following options correctly explains the concept of Polymorphism? a. 1. int func(float); 2. float func(int, int, char); b. 1. int func(int); 2. int func(int); c. 1. int func(int, int); 2. float func1(float, float); d. None of the above 1) Which of the following keywords is used to write assembly code in a C ++ program? a. ASM b. asm c. Not possible d. Compiler specific Answer: b Description: In the C ++ programming language, one can use the "asm" keyword to write assembly code as an inline function. To understand this in more detail, please consider the following example: Sample demo of "asm" keyword use: 1. #include<bits/stdc++.h> 2. usingnamespacestd; 3. intmain() 4. { 5. // generates interrupt 5 6. asmint5; 7. 8. return0; 9. } 2) Which one of the following is considered as the least safe typecasting in C++? A. const_cast B. reinterpret_cast C. dynamic_cast D. None of the above Answer: b Description: Typecasting is referred to as converting a specific expression type to another type. However, in the C++ programming language, the reinterpret_ cast is considered as the least safe typecasting. Therefore the correct answer will be option B. 3) ISO/IEC 14882:1998 addresses which version of C++? a. C++ 98 b. C++ 93 c. C++ 0 d. C++ 03 Answer: a Description: The "ISO / IEX14882:1998 represents the C++ 0x version of the C++ language that also informally known as the "C++98". Hence the correct answer will be the A. 4) Which one of the following correctly refers to the command line arguments? A. Arguments passed to the main() function B. Arguments passed to the structure-function C. Arguments passed to the class functions D. Arguments passed to any functions Answer: a Description: Command-line arguments are usually passed to the main() function from where the program's execution usually begins. 5) What will be the output if we execute the following C++ code and pass the given arguments on the terminal? 1. #include <iostream> 2. usingnamespace std; 3. int main(intargc, charconst*argv[]) 4. { 5. for(int i=0;i<argc;i++) 6. cout<<argv[i]<<"\n"; 7. } 8. 9. ================commands=============== 10. $ g++ program.cpp-o output 11. $ ./output Hello World 12. ======================================= a. ./output Hello World b. Hello World c. program.cpp Hello d. program.cpp Hello World Hide Answer Workspace Answer: a Description: As you can see in the above given C++ program, we are trying to display (or print) all the command line arguments. Therefore the list contains "./output," "Hello," "World", as shown in the output. It is quite possible that you may be thinking why the first string is not the "program. Cpp". The main reason behind this is that the first string represents the name of the program's output file. So the correct answer will be A. 6) Which of the following methods can be considered the correct and efficient way of handling arguments with spaces? A. Use single quotes B. Either single or double quotes C. Use double quotes D. There is no way of handling arguments with space Answer: b Description: We can use either single or double quotes to handle the command-line arguments with spaces in between. 7) According to you, which of the following is the correct way to interpret Hello World as a single argument? 1. $ ./output 'Hello World' 2. $ ./output "Hello World" A. Only 1 B. Only 2 C. Neither 1 nor 2 D. Both 1 and 2 Answer: d Description: Typically, both single and double quotes can be used to interpret words separated by spaces as a single argument. 8) Which of the following statements is correct about the second parameter of the main() function? A. The second parameter is an array of character pointers B. The first string of the list is the name of the program's output file C. The string in the list are separated by space in the terminal D. All of the mentioned Answer: d Description: All the statements in the above questions are related to the second parameter. Therefore the correct answer is D. 9) Which of the following is correct about the first parameter of the "main()" function? A. The first argument is of int type B. Stores the count of command-line arguments C. The first argument is non-negative D. All of the mentioned Answer: d Description: All the statements given in the above questions are true for the first parameter of the "main()"function. The first parameter is of non-negative integer type and stores the count of command-line arguments 10) Which of the following given can be considered as the correct output of the following C ++ code? 1. #include<iostream> 2. usingnamespace std; 3. int main() 4. { 5. int x=5; 6. int y=5; 7. auto check =[&x]() 8. { 9. x =10; 10. y =10; 11. } 12. check(); 13. cout<<"Value of x: "<<x<<endl; 14. cout<<"Value of y: "<<y<<endl; 15. return0; 16. } 17. A. It will result in an Error B. Value of a: 10 C. Value of a: 5 D. It will obtain Segmentation fault Answer: a Description: If you look at the above-given program carefully, you will find that the lambda expression does not capture the value of variable "y" at all. Besides, it tries to access the value of the external variable y. Thus the above-given program will obtain or result in an Error. Therefore the correct answer is A. 11) What will be the output of the following C++ code? 1. #include<iostream> 2. usingnamespace std; 3. int main() 4. { 5. int a =5; 6. auto check =[](int x) 7. { 8. if(x ==0) 9. returnfalse; 10. else 11. returntrue; 12. }; 13. cout<<check(a)<<endl; 14. return0; 15. } a. 0 b. Segmentation fault c. Error d. 1 Answer: d Description: The above program is absolutely fine. In the above program, you can observe that we have specified the return type of the expression. Hence the programs will normally work as it is able to find the return type of the expression. 12) Which of the following is usually represented by the first parameters of the main function? a. Number of command-line arguments b. List of command-line arguments c. Dictionary of command-line arguments d. Stack of command-line arguments Answer: a Description: Usually, the first parameter in the main () function or we can also say the first argument of the main () function denotes the number of command-line arguments that are passed to it. 13) What will happen when we move the try block far away from catch block? a. Reduces the amount of code in the cache b. Increases the amount of code in the cache c. Don't alter anything d. Increases the amount of code Answer: a Description: Compilers may try to move the catch-code far away from the try-code, which reduces the amount of code to keep in the cache, thus it will enhance the overall performance. 14) What will be the output of the following C++ code? 1. #include <iostream> 2. #include <string> 3. usingnamespace std; 4. int main () 5. { 6. intnum=3; 7. stringstr_bad="wrong number used"; 8. try 9. { 10. if( num ==1) 11. { 12. throw5; 13. } 14. if( num ==2) 15. { 16. throw1.1f; 17. } 18. if( num !=1|| num !=2) 19. { 20. throwstr_bad; 21. } 22. } 23. catch(int a) 24. { 25. cout<<"Exception is: "<< a <<endl; 26. } 27. catch(float b) 28. { 29. cout<<"Exception is: "<< b <<endl; 30. } 31. catch(...) 32. { 33. cout<<str_bad<<endl; 34. } 35. return0; 36. } a. Exception is 5 b. Exception is 1.1f c. Exception is 1.6g d. Wrong number used Answer: d Description: As you can see in the above-given program, we have given "3" to "num", it arising the exception called "wrong number used." So the correct answer is D. 15) What will be the output of the following C++ code? 1. #include <iostream> 2. #include <exception> 3. usingnamespace std; 4. int main () 5. { 6. try 7. { 8. double* i=newdouble[1000]; 9. cout<<"Memory allocated"; 10. } 11. catch(exception& e) 12. { 13. cout<<"Exception arised: "<<e.what()<<endl; 14. } 15. return0; 16. } a. Depends on the computer memory b. Memory will be allocated c. Exception raised d. Memory allocatedExceptionarised Answer: a Description: In the given program, the value will be allocated if there is enough memory in the system. Therefore it depends entirely on the memory of the system. Output: $ g++ expef.cpp $ a.out Memory allocated ( if enough memory is available in the system) 16) Which one of the following given statements is correct about the increment operator? a. Increment operator(or ++ ) usually adds 2 to its operand b. Decrement operator ++ subtracts 1 to its operand c. Decrement operator ++ subtracts 3 to its operand d. Increment operator (or ++ ) usually adds 1 to its operand Answer: d Description: The Increment operator (or ++) is one of the basic operators in C++. Usually, it is used in several types of loop statements for the counter. Whenever the increment operator (or ++) gets executed, it adds or made an increment of 1 to its operand. To understand it more clearly, you can consider the example given below: Example #include <iostream> using namespace std; int main() { intx,i; i=10; x=++i; cout<<"x: "<<x; cout<<"i: "<<i; return 0; } Output x: 11i: 11 17) Read the following given piece of C++ code and find out the error? 1. Class t 2. { 3. virtual void print(); 4. } a. Class " t " should contain data members b. Function print(); should be defined c. Function " print(); " should be declared as the static function d. There is no error Answer: d Description: The above-given code is correct, and there is no error at all. 18) Which one of the following statements about the pre-increment is true? a. Pre Increment is usually faster than the post-increment b. Post-increment is faster than the pre-Increment c. Pre increment is slower than post-increment d. pre decrement is slower than post-increment Answer: a Description: Pre Increment is usually faster than the post-increment because it takes one-byte instruction whereas the post-increment takes two-byte instruction. 19) Which of the following concept is used by pre-increment? a. call by value b. call by reference c. queue d. call by name Answer: b Description: The pre-increment usually uses the concept of “call by reference “as the changes are reflected back to the memory cells/variables. 20) How many types of representation are in the string? a. 3 b. 1 c. 2 d. 4 Answer: c Description: In C++, there are following two types of string representation are provided. The following types of representation are C-style character string and string class type with Standard C++. 21) What will be the output of the following C++ code? 1. #include <iostream> 2. #include <cstring> 3. using namespace std; 4. int main () 5. { 6. char str1[10] = "Hello"; 7. char str2[10] = "World"; 8. char str3[10]; 9. intlen ; 10. strcpy( str3, str1); 11. strcat( str1, str2); 12. len = strlen(str1); 13. cout<<len<<endl; 14. return 0; 15. } a. 5 b. 55 c. 10 d. 11 Answer: c Description: In the above-given program, we are concatenating the str1 and str2 and printing Its total length. Therefore the length of the final string is 10. So the correct answer is C. 22) Which one of the following given methods we usually use to append more than one character at a time? a. Append b. operator+= c. both append & operator+= d. Data Answer: c Description: C++ programming language usually allows to append more characters to string using either the inbuilt append () function or using operator overloaded += operator. 23) What is the return value of f(p, p) if the value of p is initialized to 5 before the call? Program 1. int f(int&x, int c) { 2. c = c - 1; 3. if (c == 0) return 1; 4. x = x + 1; 5. return f(x, c) * x; 6. } Note that the first parameter is passed by reference, whereas the second parameter is passed by value. a. 3024 b. 6561 c. 55440 d. 161051 Answer: b Description: In the given C++ program, we can clearly see that the c is passed by the value, but the x is passed by the reference. Therefore all functions in the given program will have the same copies of the x but different copies of the c. So the correct option is B. 24) Which one of the following given statements is not true about the references in C++? a. A reference should be initialized whenever it is declared b. A reference cannot refer to a constant value c. A reference cannot be NULL d. Once a reference is created, it cannot be later made to reference another object; it cannot be reset Answer: b Description: In C++, you can create a constant reference that refers to a constant. To understand it in more, you can consider the following program given as an example. #include<iostream> using namespace std; int main() { constint x = 10; constint& ref = x; cout<< ref; return 0; } 25) Read the following given program of C++ and predict the most appropriate output of the following program 1. #include<iostream> 2. usingnamespacestd; 3. 4. int&fun() 5. { 6. staticintx = 10; 7. returnx; 8. } 9. intmain() 10. { 11. fun() = 30; 12. cout<< fun(); 13. return0; 14. } a. It will obtain a compilation error b. It will print 30 as output c. It will print ten as output d. None of the above Answer: b Description: Whenever a function returns by the reference, it can also be used as the lvalue. However, x is declared as the static variable, it is shared among function calls, but the initialization line "static variable x= 10;" is executed only once. Therefore the function call " fun()=30, changed the x to 30, and next call "cout<<fun" simply returns the updated or modified value. So the correct answer will be the 30. 26) Read the following given program of C++ and predict the most appropriate output of the program? 1. #include<iostream> 2. usingnamespacestd; 3. 4. int&fun() 5. { 6. intx = 10; 7. returnx; 8. } 9. intmain() 10. { 11. fun() = 30; 12. cout<< fun(); 13. return0; 14. } a. It may cause the compilation error b. It may cause the runtime error c. It will work fine d. None of the above Hide Answer Workspace Answer: b Description: As you can notice in the above-given program, we return a reference to a local variable, and the memory location becomes invalid after the function call is over. Hence it most probably results in segmentation fault or runtime error. 27) Which of the following functions must use the reference? a. Copy constructor b. Destructor c. Parameterized constructor d. None of the above Answer: a Description: In general, a copy constructor is called when the object is passed by the value. You may know that, the copy constructor itself also a type of function. So if we pass an argument by value in a copy constructor, a call to copy constructor would be made to call copy constructor, which becomes a non-terminating chain of calls. Therefore compiler doesn't allow parameters to be passed by value. 28) Read the following given program of C++ and predict the most appropriate output of the program? 1. #include<iostream> 2. usingnamespacestd; 3. 4. intmain() 5. { 6. intx = 10; 7. int& ref= x; 8. ref= 20; 9. cout<< "x = "<< x <<endl ; 10. x = 30; 11. cout<< "ref = "<< ref<<endl; 12. return0; 13. } a. x=20 ref=30 b. x=20 ref=20 c. x=10 ref= 30 d. x= 30 ref=30 Hide Answer Workspace Answer: a Description: As you can see that in the above program, the "ref" is an alias of the x. Therefore if we make changes or modifies any of them, the updated one also causes to change in another. So the correct option is A. 29) Why inline functions are useful? a. Functions are large and contain several nested loops b. Usually, it is small, and we want to avoid the function calls c. The function has several static variables d. All of the above Hide Answer Workspace Answer: b Description: In general, the inline functions are very small in size and more often used in the place of the macros as they are the substitute of the macros and many times better than the macros. So the correct answer is B. 30) Which of the following statements is true about the inline functions? a. Macros do not have the returns statement, while inline function has the return statement. b. Usually, the macros are processed by the preprocessor while on the other hand inline functions are processed in the later stages of compilation. c. Inline function usually performs the type checking, whereas macros do not. d. All of the above Hide Answer Workspace Answer: d Description: In simple terms, the inline functions are just like normal functions, which are defined by the users through the "inline" keywords. Normally they are short functions that are expended by the compiler, and their arguments are evaluated for once only.The inline functions perform the type checking of the parameters, whereas micros do not check the parameters at all. However, macros are usually processed by the preprocessor, but the inline functions are processed in the upcoming stages of the compilation. There is one more major advantage of inline functions over the macros, which is, inline functions can also have the return function, whereas the macros do not have a return statement. Last but not least, the macroshave more bugs and errors, whereas the inline function does not have bugs. 31) How can a user make a c++ class in such a way that the object of that class can be created only by using the new operator, and if the user tries to make the object directly, the program will throw a compiler error? a. By making the destructor private. b. By making the constructor private. c. Not possible d. By making both constructor and destructor private. Hide Answer Workspace Answer: a Description: One can make a c++ program in which a class's object can be created using only the " new "operator, and still, if the user wants and tries to create its object directly, the program will produce a compiler error. To can understand it more clearly, you can consider the following given example. Example // in this program, Objects of test can only be created using new class Test1 { private: ~Test1() {} friend void destructTest1(Test1* ); }; // Only this function can destruct objects of Test1 voiddestructTest(Test1* ptr) { deleteptr; } int main() { // create an object Test1 *ptr = new Test1; // destruct the object destructTest1 (ptr); return 0; } 32) In C++, which of the following has the associatively of left to right? a. Addressof b. Unary operator c. Logical not d. Array element access Hide Answer Workspace Answer: d Description: In C++, the array elements have the associatively of left to right. So the correct answer will be option D. 33) A function declared as the “friend "function can always access the data in _______. a. The private part of its class. b. The part declared as public of its class. c. Class of which it is the member. d. None of the above Hide Answer Workspace Answer: c Description: In C++, a member function can always access its class member variable, irrespective of the access specifier in which the member variable is declared. Therefore a member function can always access the data of the class of which it is a member. So the answer will be option C. 34) Read the following given program of C++ and predict the most appropriate output of the program? 1. #include<iostream> 2. using namespace std; 3. 4. int x[100]; 5. int main() 6. { 7. cout<< x[99] <<endl; 8. } a. It will display 0 as output b. Its output is unpredictable c. It will display 99 as output d. None of the above Hide Answer Workspace Answer: a Description: In C++, all the uninitialized global variables are initialized to 0. Therefore the correct answer wil be option A. 35) Read the following given program of C++, and predict the most appropriate output of the program? 1. #include<iostream> 2. usingnamespacestd; 3. intx = 1; 4. voidfun() 5. { 6. intx = 2; 7. { 8. intx = 3; 9. cout<< ::x <<endl; 10. } 11. } 12. intmain() 13. { 14. fun(); 15. return0; 16. } a. 1 b. 2 c. 3 d. 0 Hide Answer Workspace Answer: a Description: Whenever the scope resolution operator is used with a variable name, it always refers to the global variable. 36) In C++, it is possible that the destructor can also be private? a. No, not at all b. May be c. Yes, it is possible. d. None of the above Hide Answer Workspace Answer: c Description: In C++, the destructor can also be private. Therefore the correct answer is C. 37) In C++, it is possible that in a "class" there can more than one destructor like the constructor? a. Yes, it is possible b. Not it not possible at all c. Both A and B d. None of the above Answer: b Description: Another important thing to keep in mind that they cannot passed arguments. 38) In C++, it is true that a destructor can be virtual? a. No, not at all b. Yew, it is true c. It may or may not be d. None of the above Answer: b Description: Yes, it is true that a destructor can be virtual. Therefore the correct answer will be option B. 39) Which of the following statements can be considered as true about the virtual function in C++? a. In general, Virtual Functions are those functions that can be overridden in the derived class with the same signature. b. Virtual functions enable runtime polymorphism in the inheritance hierarchy. c. Both A and B d. None of the above Hide Answer Workspace Answer: c Description: In object-oriented programming languages such as Pascal, and especially in C++, a virtual functions (or virtual methods) are usually inheritable as well as can be overridden. These features are an important part of the runtime polymorphism of object-oriented programming. In short, we can say that the virtual functions describe a target function to be executed; it may be possible that the target may be unknown at the compile time. Therefore the correct answer is C. 40) Which of the following given statements are correct about the pure virtual functions? 1. In a case where a class contains a pure virtual function, that class becomes an abstract class. In addition, the instance of that class also cannot be created. 2. The implementation of the pure virtual functions is not provided in a class where they are declared. a. Only 1 b. Only 2 c. Both 1& 2 d. Neither 1 nor 2 Show Answer Workspace 41) What will be the output of the following given program? 1. #include<iostream> 2. usingnamespacestd; 3. classBase 4. { 5. public: 6. virtualvoidshow() = 0; 7. }; 8. 9. classDerived : publicBase { }; 10. 11. intmain(void) 12. { 13. Derived q; 14. return0; 15. } a. It will obtain compile error because there cannot be an empty derived class b. It will obtain the compile error with "derived is abstract" warning c. Both A and B d. None of the above Hide Answer Workspace Answer: b Description: If a user does not override the pure function in the derived class, then the derived class is also converted into an abstract class. Therefore the correct option is B. 42) In C++, can a function call itself? a. Yes b. No c. Compilation error d. Runtime error Hide Answer Workspace Answer: a Description: Yes, it is correct, a function can call itself. Therefore the correct answer is A. 43) In C++, can a for loop statement contain another for loop statement? a. No b. Yes c. Runtime error d. None of the above Hide Answer Workspace Answer: b Description: In the c++ programming language, afor loop statement can contain another for loop in itself known as the nested for loop. 44) Which of the following operators has the highest precedence? a. % b. / c. * d. All have the same precedence Hide Answer Workspace Answer: d Description: All the mentioned operators in the above-given questions have the same precedence. So the correct answer is D. 45) Which of the following can be considered as the correct syntax of for loop? a. for(initialization; condition; increment/decrement operator){} b. for(initialization, condition; increment/decrement operator){} c. for(initialization; increment/decrement operator; condition;{} d. None of the above Hide Answer Workspace Answer: a Description: Usually, the for loop contains three statements and the working of these statementsis shown in the following syntax: for (statement 1; statement 2; statement 3) { // code block to be executed } statement1: initialization statement2: condition to be check statement3: increment or decrement operator 46) Which of the following is used to terminate the structure in C++? a. ; b. : c. ;; d. } Answer: b Description: In C++, to terminate the structure, a semicolon is used. 47) Inside a structure, the declared data members are known as____ a. Data b. Object & data c. Members d. None of the above Answer: c Description: The data members declared within the structure are known as the members. Therefore the correct answer is B. 48) The term modularity refers to _____. a. To divide the program into small independent parts or sub-modules. b. To override the parts of the program. c. To wrapping things into a single unit. d. None of the above. 1. Which of these types is not provided by C but is provided by C++? a. double b. float c. bool d. int Answer: (c) bool 2. Which concept do we use for the implementation of late binding? a. Static Functions b. Constant Functions c. Operator Functions d. Virtual Functions Answer: (d) Virtual functions 3. Which of these won’t return any value? a. void b. null c. free d. empty Answer: (a) void 4. Which function do we use for checking if a character is a space or a tab? a. isdigit() b. isblank() c. isalnum() d. isalpha() Answer: (b) is blank() 5. What would happen in case one uses a void in the passing of an argument? a. It would return any value b. It may not or may depend on a declared return type of any function. The return type of the function is different from the passed arguments c. It would return some value to the caller d. It would not return any value to the caller Answer: (d) It would not return any value to the caller 6. ___ modularization _______ is an ability of grouping certain lines of code that we need to include in our program? a. macros b. modularization c. program control d. specific task Answer: (b) modularization 7. Which of these keywords do we use for the declaration of the friend function? a. myfriend b. classfriend c. friend d. firend Answer: (c) friend 8. What is used for dereferencing? a. pointer with asterix b. pointer without asterix c. value with asterix d. value without asterix Answer: (a) pointer with asterix 9. What does polymorphism stand for? a. a class that has four forms b. a class that has two forms c. a class that has only a single form d. a class that has many forms Answer: (d) a class that has many forms 10. What handler do we use if we want to handle all the types of exceptions? a. try-catch handler b. catch-none handler c. catch-all handler d. catch handler Answer: (c) catch-all handler 11. What do we use in order to throw an exception? a. try b. throw c. handler d. catch Answer: (b) throw 12. We can apply RTTI to which of the class types? a. Polymorphic b. Encapsulation c. Static d. Derived Answer: (a) Polymorphic 13. Which header file do we use for the generation of random numbers? a. <random> b. <generator> c. <distribution> d. <gen_dist> Answer: (a) <random> 14. Which container is the best for keeping a collection of various distinct elements? a. queue b. set c. heap d. multimap Answer: (b) set 15. Inheritance models which type of relationship? a. Belongs-to relationship b. Part-Of relationship c. Is-A relationship d. Has-A relationship Answer: (c) Is-A relationship 16. In heap, which of these values will be pointed out first? a. First value b. Lowest value c. Third value d. Highest value Answer: (d) Highest value 17. Which of these functions is used for incrementing the iterator by a certain value? a. move() b. prev() c. advance() d. next() Answer: (c) advance () 18. In the locale object, which of these objects’ information is loaded? a. secant object b. facet object c. instead object d. both instead & facet objects Answer: (b) facet object 19. Which of these mathematics libraries is used in C++ for vector manipulation? a. blitz++ b. stac++ c. vec++ d. cli+++ Answer: (a) blitz++ 20. Which of these operators is used in order to capture every external variable by reference? a. * b.&& c. & d. = Answer: (d) 1. OOP language supports object based features, inheritance and polymorphism [A] .Encapsulation. [B}.Polymorphism [C} Object identity. [A] Functions. Answer: Option [B] 2. is one of the ways to achieve polymorphism. [A] Inheritance [B} Data overloading [C} Operator overloading. [A] Message binding. Answer: Option [C] 3. A is an instance of class [A] Code [B} object [C} variable [A] pointer Answer: Option [B] 4. One of the methods to stop the execution of the function is by calling the standard function [A] goto. [B} jump. [C} stop. [D] exit Answer: Option [D] 4. is a relationship between classes. [A] Polymorphism [B} Inheritance [C} Overloading [A] Overriding Answer: Option [B] 5. A continue statement causes execution to skip to . [A] The first statement after the loop. [B} The statement following the continue statement. [C}The return 0; statement. [D] the next iteration of the loop. Answer: Option [D] 6. A converts from an object of the type of the constructor's parameter to an object of the class. [A] Conversion function. [B}, Member function. [C}, Class conversion. [A] Conversion constructors. Answer: Option [D] 7. Variables that are declared, but not initialized, contain [A] blank spaces. [B} zeros.zzz [C}"garbage “values. [A] nothing - they are empty. Answer: Option [C] 8. When a data type must contain decimal numbers, assign the type [A] int [B} char [C} double [A] long int Answer: Option [C] 9. A structure defines a type. [A] class [B} pointers [C} arrays [A] variables Answer: Option [A] 10. Operator returns the address of the identifier. [A] &. [B} *. [C}&& [A Answer: Option [A] 11. is a stream connected to standard output. [A] cin. [B} gets [C} out [A] count Answer: Option [D] Which 12. of the following is not an arithmetic operator? [A] + [B} * [C} [A] & Answer: Option [D] 13. Which of the following is a correct comment? [A] */ Comments */. [B} ** Comment **. [C} /* Comment */. [A] { Comment }. Answer: Option [C] 14. When following piece of code is executed, what happens? b = 3; a = b++; [A] a contains 3 and b contains 4. [B} a contains 4 and b contains 4. [C} a contains 4 and b contains 3. [A] a contains 3 and b contains 3. Answer: Option [A] 15. The parameters specified in the function call are known as [A] formal [B} actual [C} value [A] original Answer: Option [B] parameters 16. Which of the following will not return a value? [A] null [B} void [C} empty [A] free Answer: Option [B] 17. Function overloading is also similar to which of the following [A] operator overloading [B} constructor overloading [C} destructor overloading [A] none of the mentioned Answer: Option [B] 18. a friend function has access to all private and protected members of the class for which it is [A] Friend [B} Member [C} Nonmember [A] Void Answer: Option [A] 19. Which is not a loop structure? [A] for [B} do while. [C} while [A] repeat until. Answer: Option [D] 20. Which one of the following is a built in function? [A] stringlen() [B} strlength(). [C} strlen(). [A] strleng(). Answer: Option [C] 21. is the process of using the same name for two or more functions [A] Function overloading. Operator [B} overloading. [C} Default function. [A] Default function. Constructors. Answer: Option [A] 22. is used to write a single character to output file. [A] cin(). [B} put(). [C} get(). [A] getw(). Answer: Option [B] 23. The technique of building new classes from existing classes is called _ . [A] Inheritance [B} overloading [C} constructor [A] Polymorphism Answer: Option [A] 24. The class which derives the property from other is called as . [A] super [B} derived [C} subordinarte [A] base Answer: Option [B]