Basics of C++ and Class Structure – MCQs July 22, 2025 by u930973931_answers 30 Score: 0 Attempted: 0/30 Subscribe 1. : Which of the following is the correct extension of a C++ source file? (A) .cp (B) .cpp (C) .cpl (D) .cxx 2. : Which operator is used to create an object of a class in C++? (A) malloc (B) new (C) create (D) alloc 3. : What is the default access specifier for class members in C++? (A) public (B) private (C) protected (D) global 4. : Which keyword is used to define a class in C++? (A) object (B) define (C) class (D) struct 5. : Which of the following is used to declare a class object in C++? (A) ClassName obj; (B) obj ClassName; (C) new ClassName; (D) declare ClassName obj; 6. : Which of the following is true about constructors in C++? (A) They can return values (B) They have the same name as the class (C) They must be private (D) They can be called manually only 7. : What is the purpose of a destructor in C++? (A) To initialize an object (B) To destroy an object and free resources (C) To overload operators (D) To inherit classes 8. : Which symbol is used to access members of a class using a pointer? (A) . (B) -> (C) :: (D) :> 9. : What is encapsulation in C++? (A) Binding data and functions into one unit (B) Dividing the program into smaller parts (C) Hiding the code from users (D) Creating new classes from existing ones 10. : What does the keyword this refer to in C++? (A) The class name (B) The current object (C) The base class (D) A pointer to the constructor 11. : What type of function can access private members of a class? (A) Any function (B) Only public functions (C) Friend function (D) Inline function 12. : Which member function automatically gets called when an object is created? (A) Destructor (B) Main (C) Constructor (D) Operator 13. : What is function overloading in C++? (A) Using functions of the same name with different parameters (B) Using multiple functions with the same body (C) Using the same function repeatedly (D) None of the above 14. : How many types of access specifiers are there in C++? (A) Two (B) Three (C) Four (D) Five 15. : What are the access specifiers in C++? (A) internal, external, global (B) public, private, protected (C) open, locked, hidden (D) general, special, common 16. : Which keyword is used for inheritance in C++? (A) inherit (B) extends (C) base (D) : (colon) 17. : What is polymorphism in C++? (A) Having multiple main functions (B) Many forms of a function or operator (C) Overriding constructors (D) Multiple base classes 18. : Which feature allows the reusability of code in OOP? (A) Inheritance (B) Encapsulation (C) Polymorphism (D) Abstraction 19. : What is the use of a virtual function in C++? (A) To hide base class methods (B) For early binding (C) For dynamic/late binding (D) To overload constructors 20. : What is the size of an empty class in C++? (A) 0 bytes (B) 1 byte (C) 2 bytes (D) 4 bytes 21. : Can a constructor be virtual in C++? (A) Yes (B) No (C) Only in derived classes (D) Only with static classes 22. : What is the role of the public keyword before a base class during inheritance? (A) Makes base class private (B) Makes base class members public in derived class (C) Retains original access level (D) Prevents inheritance 23. : How do you declare a constant member function in a class? (A) void func(); (B) const void func(); (C) void const func(); (D) void func() const; 24. : Can static member functions access instance variables? (A) Yes (B) No (C) Only private variables (D) Only in base class 25. : Which of the following is true about inline functions? (A) They increase the execution time (B) They reduce function-call overhead (C) They must return void (D) They cannot be part of a class 26. : Which concept hides internal object details from the user? (A) Abstraction (B) Inheritance (C) Polymorphism (D) Overloading 27. : How is dynamic memory allocated for objects in C++? (A) Using malloc (B) Using alloc (C) Using new (D) Using malloc_object 28. : What is a static member in C++? (A) A member that cannot be modified (B) A member shared by all objects (C) A member only accessible by the class (D) A member with local scope 29. : What is operator overloading in C++? (A) Using operator inside function (B) Changing the meaning of an operator (C) Using multiple operators in one statement (D) None of the above 30. : Which of the following allows object creation without using the class name explicitly? (A) Pointer (B) Inheritance (C) Friend class (D) Factory method