1. Which function serves as the entry point in a C++ program?
A) main()
B) start()
C) init()
D) entry()
Show Explanation
2. What is the purpose of a destructor in C++?
A) To initialize an object
B) To clean up an object
C) To overload operators
D) To implement inheritance
Show Explanation
3. How do you deallocate memory in C++ that was allocated with 'new'?
A) free()
B) remove()
C) clear()
D) delete
Show Explanation
4. What does the sizeof() operator return?
A) The size of a data type in bytes
B) The length of a string
C) The size of a variable in kilobytes
D) The memory address of a variable
Show Explanation
5. Which namespace is used in C++ for standard functions like cout and cin?
A) standard
B) global
C) std
D) library
Show Explanation
6. Which C++ keyword is used to take input from the user through the console?
A) cout
B) cin
C) in
D) scanf
Show Explanation
7. What does the scope resolution operator (::) do in C++?
A) Declares a variable
B) Initializes an object
C) Ends a statement
D) Accesses a global variable
Show Explanation
8. Which keyword is used in C++ to declare a constant variable?
A) final
B) static
C) const
D) constant
Show Explanation
9. What is a copy constructor in C++?
A) A constructor that initializes an object with another object
B) A constructor that returns a pointer
C) A constructor that copies variables from one class to another
D) None of the above
Show Explanation
10. What does the 'continue' statement do in a C++ loop?
A) Exits the loop
B) Repeats the loop
C) Breaks the loop
D) Skips to the next iteration
Show Explanation
11. What is a friend function in C++?
A) A function that returns a pointer to a class
B) A function that can access private and protected members
C) A member function that accesses only public data
D) A function defined outside a class
Show Explanation
12. Which concept in C++ allows functions to have multiple definitions based on input?
A) Polymorphism
B) Inheritance
C) Encapsulation
D) Abstraction
Show Explanation
13. Which keyword is used to deallocate memory in C++ that was allocated with 'new'?
A) free
B) dealloc
C) delete
D) destroy
Show Explanation
14. Which loop in C++ is best used when the number of iterations is known?
A) for
B) while
C) do-while
D) foreach
Show Explanation
15. What is a virtual function in C++?
A) A function that can only be used with pointers
B) A function that can be overridden in derived classes
C) A function without a return type
D) A function that cannot be overridden
Show Explanation
16. Which operator is used to assign a value to a variable in C++?
A) ==
B) :=
C) =
D) ->
Show Explanation
17. What is a pointer in C++?
A) A variable that stores the address of another variable
B) A variable that holds a function
C) A variable that stores the length of an array
D) A special type of integer
Show Explanation
18. Which operator in C++ is used to get the size in bytes of a data type?
A) lengthof()
B) bytes()
C) len()
D) sizeof()
Show Explanation
19. Which keyword is used in C++ for dynamic memory allocation?
A) malloc
B) calloc
C) new
D) dynamic
Show Explanation
20. What is operator overloading in C++?
A) Allowing multiple types for operators
B) Redefining operators for user-defined types
C) Using operators with classes only
D) Using operators with functions only
Show Explanation