Professional Documents
Culture Documents
CSE_THEORY
CSE_THEORY
Ans) Object oriented programming has four main features. They are:
1) Encapsulation: This feature of OOP allows for data hiding, as the data (attributes) of the object
is hidden from the outside world, and can only be accessed through the methods of the object.
2) Inheritance: This is a feature that allows one class (the child class) to inherit the properties and
methods of another class (the parent class). This promotes code reusability.
3) Polymorphism: This is a feature that allows one interface to be used for a general class of
actions. This means that the exact method that gets called is determined at runtime, not at
compile time.
4) Abstraction: This is a feature that allows complex real world problems to be simplified by
modelling them in a way that captures only the required details.
Ans) A class is a user defined data type. It is a blueprint for declaring and creating objects.
An object is a class instance that allows programmers to use variables and methods from
I inside the class. Example:
Ans) A code will be given in the question, you will have to describe that code.
Definition of Constructors and Destructors with example.
Ans) Constructors are special member functions that are automatically called when and object is
. created.
Destructors are special member functions that are automatically called when an object is .
I destroyed. They are used to free up memory. Example:
Ans) A friend function is a function that can access the private and protected members of a class even
though it is not a member of that class. So the advantage of friend function is that it allows the
sharing of private class information by a non-member function.
Copy constructor.
Ans) A Copy constructor is a special member function that creates a new object by copying the data
from another object of the same class.
Inline function.