1. What is the default value of an int variable in C++?
ANS : (c) In C++, local variables are not initialized by default, leading to undefined behavior.
2. Which of the following is not a primitive data type in C++?
ANS : (c) string is a class in C++, not a primitive data type.
3. What is the size of a char in C++?
ANS : (a) The size of a char in C++ is 1 byte.
4. Which keyword is used to define a constant variable in C++?
ANS : (b) The const keyword is used to define a constant variable in C++.
5. Which operator is used for concatenating strings in C++?
ANS : (a) The + operator is used for concatenating strings in C++.
6. What will be the output of std::cout << 10 / 3;?
ANS : (a) The output will be 3 because both operands are integers.
7. Which of the following is used to take input in C++?
ANS : (a) The cin object is used to take input in C++.
8. How do you declare an array in C++?
ANS : (c) The correct way to declare an array in C++ is int arr[] = new int[5];.
9. What is the correct syntax to create an object in C++?
ANS : (b) The correct syntax to create an object in C++ is ClassName obj = new ClassName();.
10. What is the purpose of the this keyword in C++?
ANS : (a) The this keyword refers to the current instance of the class.
11. Which of the following is a valid way to comment in C++?
ANS : (c) Both // and /* */ are valid ways to comment in C++.
12. What is the output of the following code: std::cout << "Hello" << 5;?
ANS : (a) The output will be Hello5.
13. Which of the following is used to handle exceptions in C++?
ANS : (c) Both try-catch and throw are used to handle exceptions in C++.
14. What does a C++ class hold?
ANS : (a) A C++ class holds both data members and member functions.
15. Which of the following is a feature of Object-Oriented Programming in C++?
ANS : (d) All of the above are features of Object-Oriented Programming in C++.
16. What is the purpose of the destructor in C++?
ANS : (c) The destructor is used to free resources when an object goes out of scope.
17. Which of the following is the correct way to declare a pointer in C++?
ANS : (a) The correct way to declare a pointer in C++ is int *ptr;.
18. What is the output of the following code: std::cout << (5 + 3) * 2;?
ANS : (a) The output will be 16 because (5 + 3) * 2 = 16.
19. Which of the following is used to define a function in C++?
ANS : (d) All of the above are valid ways to define a function in C++.
20. What is the purpose of the static keyword in C++?
ANS : (c) The static keyword is used to create both static variables and static functions.
21. What is the correct syntax to output "Hello World" in C++?
ANS : (a) cout << "Hello World"; is the correct syntax in C++.
22. Which header file is required for using 'cout' in C++?
ANS : (b) 'iostream' is the header file required for using cout in C++.
23. Which of the following is the correct way to declare a constant in C++?
ANS : (c) const int x = 10; is the correct way to declare a constant in C++.
24. Which operator is used to allocate memory dynamically in C++?
ANS : (c) The 'new' operator is used to allocate memory dynamically in C++.
25. What is the size of 'int' data type (typically) in C++?
ANS : (d) The size of 'int' can vary depending on the system and compiler.
26. What is the output of: cout << 5 / 2;
ANS : (b) Integer division in C++ gives 2.
27. Which of the following is used to define a class in C++?
ANS : (a) The keyword 'class' is used to define a class in C++.
28. Which of the following correctly initializes an array in C++?
ANS : (a) Correct array initialization in C++ is: int arr[3] = {1, 2, 3};
29. What is the keyword used to inherit a class in C++?
ANS : (d) Colon (:) is used to inherit a class in C++.
30. Which of the following is the correct destructor declaration in C++?
ANS : (a) ~ClassName(); is the correct way to declare a destructor.
31. Which of the following is not a C++ access specifier?
ANS : (c) 'internal' is not a valid access specifier in C++.
32. Which of the following supports function overloading in C++?
ANS : (b) Function overloading is supported with same name and different parameters.
33. What is the default return type of functions in C++ if not specified?
ANS : (b) The default return type in older C++ standards is int.
34. What is a constructor in C++?
ANS : (d) A constructor has all these properties.
35. What will 'cin' do in C++?
ANS : (b) 'cin' is used for user input in C++.
36. Which loop checks the condition after executing the loop body?
ANS : (c) do-while executes body first, then checks condition.
37. What is the scope resolution operator in C++?
ANS : (b) :: is the scope resolution operator in C++.
38. What does the 'this' pointer point to in C++?
ANS : (b) 'this' pointer refers to the current object.
39. What is the extension of a C++ source file?
ANS : (b) .cpp is the standard extension for C++ source files.
40. Which of the following allows you to reuse code in C++?
ANS : (b) Inheritance allows code reuse by deriving new classes.
41. What is polymorphism in C++?
ANS : (a) Polymorphism means having multiple forms of the same function or operator.
42. Which operator is used to allocate memory dynamically in C++?
ANS : (c) The 'new' operator is used for dynamic memory allocation in C++.
43. Which of the following is a valid identifier in C++?
ANS : (b) Identifiers can start with an underscore or a letter, but not with a digit or symbol.
44. What is the size of 'int' on most 32-bit systems in C++?
ANS : (b) On most 32-bit systems, 'int' typically occupies 4 bytes.
45. Which feature in C++ is used to hide internal object details?
ANS : (b) Encapsulation hides the internal details of an object from outside interference.
46. Which of the following header files is used for input/output in C++?
ANS : (a) 'iostream' is used for standard input/output operations in C++.
47. What is the purpose of the 'return 0;' statement in C++ main() function?
ANS : (d) All of the above statements are true about 'return 0;'.
48. What is a reference variable in C++?
ANS : (b) A reference variable is an alias or alternate name for another variable.
49. Which of these is not a feature of Object Oriented Programming in C++?
ANS : (c) Compilation is a process, not a feature of OOP.
50. Which concept allows treating derived class objects as base class objects?
ANS : (c) Upcasting allows treating derived class objects as base class objects.