0% found this document useful (0 votes)
9 views3 pages

CPP Handwritten Questions

C++ is an object-oriented programming language that extends C, incorporating key OOP concepts such as encapsulation, abstraction, inheritance, and polymorphism. The document covers fundamental aspects of C++, including classes, objects, constructors, destructors, and various types of function and operator overloading. It also discusses memory management, access specifiers, exception handling, and the Standard Template Library (STL).
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

CPP Handwritten Questions

C++ is an object-oriented programming language that extends C, incorporating key OOP concepts such as encapsulation, abstraction, inheritance, and polymorphism. The document covers fundamental aspects of C++, including classes, objects, constructors, destructors, and various types of function and operator overloading. It also discusses memory management, access specifiers, exception handling, and the Standard Template Library (STL).
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

1. Q: What is C++?

A: C++ is an object-oriented programming language developed as an extension of C


by Bjarne Stroustrup.

2. Q: What are the basic concepts of OOP in C++?


A: Encapsulation, Abstraction, Inheritance, Polymorphism.

3. Q: What is the difference between C and C++?


A: C is procedural; C++ is both procedural and object-oriented.

4. Q: What is a class in C++?


A: A class is a user-defined blueprint for creating objects with data members
and member functions.

5. Q: What is an object?
A: An object is an instance of a class.

6. Q: What is encapsulation?
A: Encapsulation is wrapping data and functions into a single unit (class).

7. Q: What is abstraction?
A: Abstraction hides internal implementation and shows only essential features.

8. Q: What is inheritance?
A: Inheritance allows a class to acquire properties and behaviors of another
class.

9. Q: What is polymorphism?
A: Polymorphism means one interface, many implementations.

10. Q: What is function overloading?


A: Defining multiple functions with the same name but different parameters.

11. Q: What is operator overloading?


A: Giving new meaning to existing operators for user-defined data types.

12. Q: What is a constructor?


A: A constructor is a special function that initializes an object.

13. Q: What is a destructor?


A: A destructor is a special function that is called when an object is
destroyed.

14. Q: What are the types of constructors?


A: Default, parameterized, copy constructors.

15. Q: What is constructor overloading?


A: Having multiple constructors with different parameters.

16. Q: What is a copy constructor?


A: It creates a new object as a copy of an existing object.

17. Q: What is the difference between constructor and method?


A: Constructor initializes the object; method performs operations.

18. Q: What is this pointer?


A: `this` is a pointer that points to the current object.

19. Q: What is a friend function?


A: A function that is not a member but can access private members of a class.

20. Q: What is a static member?


A: A member shared by all objects of a class.

21. Q: What is inheritance in C++?


A: Mechanism of deriving a new class from an existing one.

22. Q: What are access specifiers?


A: Keywords that define access level: public, private, protected.

23. Q: What is virtual function?


A: A function that can be overridden in a derived class and supports runtime
polymorphism.

24. Q: What is pure virtual function?


A: A virtual function with `= 0`, making the class abstract.

25. Q: What is an abstract class?


A: A class with at least one pure virtual function.

26. Q: What is multiple inheritance?


A: A class inherits from more than one base class.

27. Q: What are virtual base classes?


A: Used to avoid ambiguity in multiple inheritance.

28. Q: What is dynamic binding?


A: The function call is resolved at runtime.

29. Q: What is static binding?


A: The function call is resolved at compile time.

30. Q: What is the use of the `new` and `delete` operators?


A: `new` allocates memory dynamically; `delete` frees it.

31. Q: What is the difference between `malloc` and `new`?


A: `malloc` is from C and doesn't call constructor; `new` is from C++ and does.

32. Q: What is exception handling?


A: Mechanism to handle runtime errors using `try`, `catch`, and `throw`.

33. Q: What is STL?


A: Standard Template Library, provides generic classes and functions.

34. Q: What are templates?


A: Templates allow functions and classes to operate with generic types.

35. Q: Difference between class and structure in C++?


A: By default, members are private in class; public in structure.

36. Q: What is namespace?


A: Namespace avoids name conflicts by grouping entities under a name.

37. Q: What is the use of `using namespace std;`?


A: It allows direct access to the `std` namespace.

38. Q: What are access specifiers?


A: public, private, protected — they define how class members can be accessed.
39. Q: What is an inline function?
A: A function where the compiler replaces the function call with the function
code.

40. Q: What is the difference between overloading and overriding?


A: Overloading: same name, different parameters; Overriding: redefining base
class function.

41. Q: What is the difference between deep and shallow copy?


A: Shallow copy copies references; deep copy copies actual content.

42. Q: What is the `typeid` operator?


A: It returns type information during runtime.

43. Q: What is RTTI?


A: Runtime Type Information allows determination of object type at runtime.

44. Q: What is the role of access specifiers in inheritance?


A: They determine accessibility of base class members in the derived class.

45. Q: What are smart pointers?


A: Smart pointers like `unique_ptr`, `shared_ptr` manage memory automatically.

46. Q: What is the difference between `==` and `equals()`?


A: `==` compares addresses; `equals()` compares values (in Java, not C++).

47. Q: What is the difference between stack and heap memory?


A: Stack is fast, limited, and local; heap is larger and used for dynamic
allocation.

48. Q: What is the use of `const` keyword?


A: It makes variables unchangeable after initialization.

49. Q: Can a constructor be virtual?


A: No, constructors cannot be virtual.

50. Q: Can we overload the destructor?


A: No, destructors cannot be overloaded.

51. Q: What is the default access specifier for classes and structs?
A: Class: private; Struct: public.

You might also like