Object Oriented Programming Interview
Questions With Correct Answers.
What is OOPS? - Answer✔OOPS is abbreviated as Object Oriented Programming system in
which programs are considered as a collection of objects. Each object is nothing but an instance
of a class.
Write basic concepts of OOPS? - Answer✔Abstraction.
Encapsulation.
Inheritance.
Polymorphism.
What is a class? - Answer✔A class is simply a representation of a type of object. It is the
blueprint/ plan/ template that describes the details of an object.
What is an object? - Answer✔An object is an instance of a class. It has its own state, behavior,
and identity.
What is Encapsulation? - Answer✔Encapsulation is an attribute of an object, and it contains all
data which is hidden. That hidden data can be restricted to the members of that class.
Levels are Public, Protected, Private, Internal and Protected Internal.
What is Polymorphism? - Answer✔Polymorphism is nothing but assigning behavior or value in
a subclass to something that was already declared in the main class. Simply, polymorphism takes
more than one form.
What is Inheritance? - Answer✔Inheritance is a concept where one class shares the structure and
behavior defined in another class. If inheritance applied on one class is called Single Inheritance,
and if it depends on multiple classes, then it is called multiple Inheritance.
What are manipulators? - Answer✔Manipulators are the functions which can be used in
conjunction with the insertion (<<) and extraction (>>) operators on an object. Examples are endl
and setw.
1|Page
, ©BRIGHSTARS 2024/2025 ALL RIGHTS RESERVED.
Define a constructor? - Answer✔A constructor is a method used to initialize the state of an
object, and it gets invoked at the time of object creation. Rules for constructor are:
-Constructor Name should be same as class name.
-A constructor must have no return type.
Define Destructor? - Answer✔A destructor is a method which is automatically called when the
object is made of scope or destroyed. Destructor name is also same as class name but with the
tilde symbol before the name.
What is an Inline function? - Answer✔An inline function is a technique used by the compilers
and instructs to insert complete body of the function wherever that function is used in the
program source code.
What is a virtual function? - Answer✔A virtual function is a member function of a class, and its
functionality can be overridden in its derived class. This function can be implemented by using a
keyword called virtual, and it can be given during function declaration.
A virtual function can A token in C++, and it can be achieved in C Language by using function
pointers or pointers to function.
What is a friend function? - Answer✔A friend function is a friend of a class that is allowed to
access to Public, private or protected data in that same class. If the function is defined outside the
class cannot access such information.
Friend can be declared anywhere in the class declaration, and it cannot be affected by access
control keywords like private, public or protected.
What is function overloading? - Answer✔Function overloading an as a normal function, but it
can perform different tasks. It allows the creation of several methods with the same name which
differ from each other by the type of input and output of the function.
Example
void add(int& a, int& b);
void add(double& a, double& b);
void add(struct bob& a, struct bob& b);
2|Page