CPP Interview Questions for fresher

  1. What is C++?

    • C++ is a general-purpose programming language that is an extension of the C programming language. It supports both procedural and object-oriented programming paradigms.
  2. What is the difference between C and C++?

    • C++ is an extension of C and includes features like classes and objects, inheritance, polymorphism, and encapsulation, which are not present in C.
  3. Explain the concept of Object-Oriented Programming (OOP) and its pillars.

    • OOP is a programming paradigm that uses objects and classes. The four pillars of OOP are encapsulation, inheritance, polymorphism, and abstraction.
  4. What is a class and an object in C++?

    • A class is a blueprint for creating objects, and an object is an instance of a class.
  5. What is the difference between public, private, and protected access specifiers?

    • Public members are accessible from outside the class, private members are only accessible within the class, and protected members are accessible within the class and its subclasses.
  6. Explain the concept of constructor and destructor in C++.

    • A constructor is a special member function that is called when an object is created. A destructor is a special member function that is called when an object goes out of scope or is explicitly deleted.
  7. What is function overloading and operator overloading?

    • Function overloading is the ability to define multiple functions with the same name but different parameter lists. Operator overloading is the ability to redefine the behavior of operators for user-defined data types.
  8. What is the difference between reference and pointer?

    • A reference is an alias for a variable, and once a reference is initialized, it cannot be changed to refer to another variable. A pointer is a variable that stores the address of another variable, and it can be changed to point to a different variable.
  9. What is dynamic memory allocation in C++?

    • Dynamic memory allocation in C++ is done using operators new and delete or malloc() and free(). It allows the allocation and deallocation of memory during program execution.
  10. Explain the concept of virtual functions and pure virtual functions.

    • Virtual functions are functions declared in a base class that can be overridden by derived classes. A pure virtual function is a virtual function with no implementation in the base class, making it necessary for derived classes to provide an implementation.
  11. What is the use of the const keyword in C++?

    • The const keyword is used to declare constants, indicate that a variable cannot be modified, and specify that a member function does not modify the object it is called on.
  12. Explain the difference between pass by value and pass by reference.

    • Pass by value involves passing the actual value of a variable to a function, while pass by reference involves passing the memory address (reference) of a variable. Changes made to the parameter in pass by reference affect the original variable.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

63810