Frequently asked questions and answers of C++ in Programming Technologies of Computer Science to enhance your skills, knowledge on the selected topic. We have compiled the best C++ Interview question and answer, trivia quiz, mcq questions, viva question, quizzes to prepare. Download C++ FAQs in PDF form online for academic course, jobs preparations and for certification exams .
Intervew Quizz is an online portal with frequently asked interview, viva and trivia questions and answers on various subjects, topics of kids, school, engineering students, medical aspirants, business management academics and software professionals.
Question-1. What is C++?
Answer-1: C++ is a general-purpose programming language that supports procedural, object-oriented, and generic programming.
Question-2. Who developed C++ and when?
Answer-2: C++ was developed by Bjarne Stroustrup in 1983.
Question-3. What are the key features of C++?
Answer-3: Key features include object-oriented programming, operator overloading, templates, and memory management.
Question-4. What is the difference between C and C++?
Answer-4: C is procedural, while C++ supports object-oriented programming and additional features like classes and templates.
Question-5. What is a class in C++?
Answer-5: A class is a blueprint for creating objects that encapsulate data and functions.
Question-6. What is an object in C++?
Answer-6: An object is an instance of a class, representing real-world entities.
Question-7. What is the difference between struct and class in C++?
Answer-7: In C++, the default access modifier for a struct is public, while for a class, it is private.
Question-8. What are C++ access specifiers?
Answer-8: Access specifiers include public, private, and protected.
Question-9. What is a constructor in C++?
Answer-9: A constructor is a special member function that initializes objects of a class.
Question-10. What is a destructor in C++?
Answer-10: A destructor is a member function that cleans up resources when an object is destroyed.
Question-11. What is the difference between a shallow copy and a deep copy in C++?
Answer-11: A shallow copy duplicates pointers, while a deep copy duplicates the actual data.
Question-12. What is operator overloading in C++?
Answer-12: Operator overloading allows defining custom behavior for operators when applied to objects.
Question-13. What are C++ templates?
Answer-13: Templates enable generic programming by allowing functions and classes to work with any data type.
Question-14. What is function overloading in C++?
Answer-14: Function overloading allows multiple functions with the same name but different parameter types or counts.
Question-15. What is function overriding in C++?
Answer-15: Function overriding allows a derived class to provide a specific implementation of a base class method.
Question-16. What is inheritance in C++?
Answer-16: Inheritance allows a class to derive properties and behavior from another class.
Question-17. What are the types of inheritance in C++?
Answer-17: Types include single, multiple, multilevel, hierarchical, and hybrid inheritance.
Question-18. What is polymorphism in C++?
Answer-18: Polymorphism allows functions or methods to operate differently based on the object they act upon.
Question-19. What is the difference between compile-time and run-time polymorphism in C++?
Answer-19: Compile-time polymorphism is achieved using function overloading and templates; run-time polymorphism is achieved using virtual functions.
Question-20. What is a virtual function in C++?
Answer-20: A virtual function allows a derived class to override a method of its base class.
Question-21. What is a pure virtual function?
Answer-21: A pure virtual function is a function declared in a base class and must be overridden in derived classes.
Question-22. What is an abstract class in C++?
Answer-22: An abstract class has at least one pure virtual function and cannot be instantiated.
Question-23. What is the difference between new and malloc() in C++?
Answer-23: new initializes objects and calls constructors; malloc() only allocates memory.
Question-24. What is a namespace in C++?
Answer-24: A namespace prevents name conflicts by encapsulating identifiers in a distinct scope.
Question-25. What are C++ access modifiers?
Answer-25: Access modifiers control access to class members and include public, private, and protected.
Question-26. What is the difference between references and pointers in C++?
Answer-26: References are aliases for variables and must be initialized, while pointers store memory addresses and can be reassigned.
Question-27. What is the purpose of this pointer in C++?
Answer-27: The this pointer points to the current instance of a class.
Question-28. What is dynamic binding in C++?
Answer-28: Dynamic binding occurs when a function call is resolved at runtime using virtual functions.
Question-29. What is static binding in C++?
Answer-29: Static binding occurs when a function call is resolved at compile time.
Question-30. What are smart pointers in C++?
Answer-30: Smart pointers manage memory automatically and include unique_ptr, shared_ptr, and weak_ptr.
Question-31. What is an inline function in C++?
Answer-31: An inline function is expanded at the point of its call to reduce overhead.
Question-32. What is the difference between struct and class in C++?
Answer-32: struct members are public by default; class members are private by default.
Question-33. What are C++ exception handling keywords?
Answer-33: Keywords include try, catch, throw, and finally.
Question-34. What is the Standard Template Library (STL) in C++?
Answer-34: STL is a library that provides generic classes and functions for data structures and algorithms.
Question-35. What is a vector in C++?
Answer-35: A vector is a dynamic array that can grow and shrink in size.
Question-36. What is the difference between vector and array in C++?
Answer-36: vector is dynamic and resizable; array has a fixed size.
Question-37. What is the difference between stack and heap memory in C++?
Answer-37: Stack memory is used for static and local variables, while heap memory is used for dynamic allocation.
Question-38. What is a friend function in C++?
Answer-38: A friend function can access private and protected members of a class.
Question-39. What is function overriding in C++?
Answer-39: Function overriding allows a derived class to provide its implementation of a base class method.
Question-40. What is the difference between deep copy and shallow copy?
Answer-40: A deep copy duplicates objects, while a shallow copy duplicates references.
Question-41. What is a static function in C++?
Answer-41: A static function belongs to the class rather than an instance of the class.
Question-42. What is multiple inheritance in C++?
Answer-42: Multiple inheritance allows a class to inherit from more than one base class.
Question-43. What is a virtual destructor in C++?
Answer-43: A virtual destructor ensures proper cleanup of derived class resources.
Question-44. What is RAII in C++?
Answer-44: Resource Acquisition Is Initialization (RAII) manages resources using object lifetimes.
Question-45. What is the mutable keyword in C++?
Answer-45: The mutable keyword allows a member variable to be modified even in a const object.
Question-46. What are C++ streams?
Answer-46: Streams are used for input and output operations, such as cin and cout.
Question-47. What is the role of the virtual keyword in C++?
Answer-47: The virtual keyword enables dynamic binding and polymorphism.
Question-48. What is the explicit keyword in C++?
Answer-48: The explicit keyword prevents automatic conversions for constructors.
Question-49. What is the difference between public, protected, and private inheritance in C++?
Answer-49: These determine the visibility of base class members in the derived class.
Question-50. How do you implement a singleton class in C++?
Answer-50: Use a private constructor, a static method, and a static instance to implement a singleton.
Frequently Asked Question and Answer on C++
C++ Interview Questions and Answers in PDF form Online
C++ Questions with Answers
C++ Trivia MCQ Quiz