Friday, June 18, 2021
Home interview preparation 50+ most asked OOPS Interview Question.

50+ most asked OOPS Interview Question.

Dear User, if you are preparing for interviews looking for most asked OOP interview question, so you landed on right platform
here we will provide you top 50+ question which help you to crack any interviews easily.


1.What is OOP?

Answer:OOPS stand for Object oriented programming which provide the feature of abstraction,encapsulation,polymorphism,inheritance.


2.What are the main features of object-oriented programming?

Answer:

feature of object-oriented programming are:

1-oops can be implemented using class and object. which make code design looks clean.

2-it support reusabilty feature.

3-oops model support the real world example.

4-complexity can easily be managed.

3.What are the advantages of Object-oriented programming?

Answer:

Advantage of Object-Oriented programming are:

1-it support data abstraction.

2-it support encapsulation.

3-it support polymorphism.

4-it support inheritance.


4.What is a class?

Answer:

class is a user defined data type which is blueprint of object.

it is declared with class keyword.


5.What do you mean by an object?

Answer:

Object is an abstract data type which is instance of class.


6.What are the difference between object oriented and procedural language?

Answer:

Object oriented programmingProcedural language
1-it is callled as OOP.1-it is called as POP.
2-it works on data.2-it works on algorithm..
3-it is more secure3-it is not secure


7.Explain encapsulation with real example.

Answer:

Encapsulation is a process in which data and their function are bind together to form a single unit.

for example:

A mobile number stores the contact detail in digital format and convert it into human readable form.and we dont know how mobile number is stored .and how it is converted in human readable form.


8.explain polymorphism.with real life example?

Answer:

polymorphism is a process which has the ability to keep same thing in multiple form.

For example:

A person is a son of his father ,husband of his wives and at the same time he is employee of company.that mean a person can exist in many form in a same time.


9.explain inheritance.with real life example?

Answer:

Inheritance is a process in which a class derived the properties from another class or parent class.

For example:

like in our family ,our parent are super class and we are the child class because we are inheriting properties from our parent.


10.explain abstraction.with real life example?

Answer:

Abstraction is a process in which we hide the implementation detail of the code and we are showing only the important detail to the end user.

for example:

if we take a example of motor bike,we know when we increase the accelerator then speed automatically increase but we dont know how it is happening .this is when abstraction come in play it hide the background detail and show only important info.


11.What is the difference between OOP and SOP?

Answer:

OOPSOP
1-it is based on object and class.1-it provide logical structure
2-it support data hiding.2-it does not support data hiding.
3-bottom up approach3-top down approach.


12.What is the difference between a class and a structure?

Answer:

structureclass
1-struct keyword used1-class keyword used.
2-it is a data type which store the various data type.2-it is blueprint of object
3-by default member are public.3-by default member are private.


13.What is the difference between a class and an object?

Answer:

classobject
1-it is blueprint of object.1-it is instance of class.
2-it is logical entity.2-it is physical entity.
3-no memory is allocated .3-each object has its memory.


14.What are the different types of inheritance?

Answer:

there are different type of inheritance:

1-single inheritance.

2-multiple inheritance.

3-hybrid inheritance.

4-multilevel inheritance.

5-hierarchial inheritance


15.What is the difference between multiple and multilevel inheritance?

Answer:

multiple inheritance:

if class inherit from more than one classes then that is called multiple inheritance.

multilevel inheritance:

if derived class is inherited from another derived class then that is called multilevel inheritance.


16.What is hybrid inheritance?

Answer:

hybrid inheritance formed after joining different type of inheritance.


17.What is hierarchical inheritance?

Answer:

if more than one derived class is inherited from one base class is called hierarchical inheritance.


18.What are the limitations of inheritance?

Answer:

limitation of inheritance are:

1-they are not independent of each other.

2-it form tightly coupled relationship.


19.Explain the term constructor

Answer:

constructor is a member function which initialize when object is created.


20.Define Destructor?

Answer:

destructor is a function which automatically invokes to destroy object.


21.What is an Inline function?

Answer:

The inline function in c++ is used to increase the execution time of program.


22.What is a virtual function?

Answer:

Virtual function is a function which is declared in base class and overriden by the derived class.


23.What is a friend function?

Answer:

when any function is declared as friend,it can access private and protected member of the class.

A function start with friend keyword is known as friend function.


24.What is a superclass?

Answer:

super class is a parent class from which classes are being inherited.


25.What is a subclass?

Answer:

sub class is a class which is inherit form another class.


26.What is polymorphism?

Answer:

polymorphism is a process which has the ability to keep same thing in multiple form.

For example:

A person is a son of his father ,husband of his wives and at the same time he is employee of company.that mean a person can exist in many form in a same time.

there are two type of polymorphism.

1-static polymorphism .

2-run time polymorphism.


27.What is static polymorphism?

Answer:

static polymorphism are the polymorphism which resolved at compile time.

overloading is an example of static polymorphism.


28.What is dynamic polymorphism?

Answer:

Runtime polymorphism are the polymorphism which resolved at runtime.

overriding is an example of static polymorphism.


29.What is method overloading?

Answer:

In method overloading, we define two or more method in the same class by same name but diffrent argument is called overloading.


30.What is method overriding?

In method overriding,if the method name and parameter are same in super class and the child class is called overriding.


31.What is operator overloading?

Answer:

operator overloading allow to define new data type from the builtin data type.


32.Differentiate between overloading and overriding.

Answer:

In overloading, we define two or more method in the same class by same name but diffrent argument is called overloading.

In overriding,if the method name and parameter are same in super class and the child class is called overriding.


33.What are access specifiers?

Answer:

access specifiers is used to define accessibility of class.by default variable and function are declared private.

there are three access specifier:

1-public.

2-private.

3-protected.


34.What is the difference between public, private and protected access modifiers?

1-public: member which declare public are accessible outside the class.

2-private:member which declared private are only accessible within class.

3-protected:member which declare protected are acccessible in derived class.


35.How to achieve data abstraction?

Answer:

we can acheive data abstraction by using interface and abstract class.


36.What is an abstract class?

Answer:

Abstract keyword is used to define abstract class.it consist of abstract function and non abstract function.


37.What is an interface?

Answer:

interface keyword is used to define interface.it is collection of abstract method. by default only public access specifier are there.


38.What is a ternary operator?

Answer:

ternary operator is operator which take three operands .it is represented as a?b:c.


39.What is the use of finalize method?

Answer:

finalize method is used to perform clean up operation.


40.What is the super keyword?

Answer:

super keyword is a reference variable of parent object.


41.What is exception handling?

Answer:

Exception Handling is defined as the process in which we handle exception /error while executing the program.

yes c++ support exception handling.

try ,throw and catch block is used to handle exception in c++.


42.Differentiate between data abstraction and encapsulation.

AbstractionEncapsulation
1-Abstraction is a process in which we hide the implementation detail of the code and we are showing only the important detail to the end user.1-Encapsulation is a process in which data and their function are bind together to form a single unit.
2-it solve problem in design level2-it solve the problem in implementation level.
3-we use abstraction by using interface and abstract class.3-we use encapsulation by using access specifier.


43.What are pure virtual functions?

Answer:

A pure virtual function is a function which is declared 0.


44.What is a constructor?

Answer:

constructor is a member function which initialize when object is created.


45.What is a destructor?

Answer:

destructor is a function which automatically invokes to destroy object.


46.Types of constructors

there are various type of constructor are:

1-copy constructor.

2-default constructor.

3-parametric constructor.


47.What is a copy constructor?

Answer:

copy constructor is a constructor which initialise the object by another object of the same class.


48.What is Garbage Collection(GC)?

Answer:

it is process which is used to destroy unused object.


49.Differentiate between an abstract class and an interface?

Answer:

Abstract ClassInterface
1-abstract keyword is used1interface keyword is used.
2-all access modifier are there2-only public access modifier are there
3-we use it when we have to avoid independence.3-we use it for future enhancement.
4-speed is fast4-speed is slow.


50.What is a try/ catch block?

Answer:

try/catch block is used for exception handling.

try block define the block of statement which is being tested for error.

catch block define the block of statement which execute after error occur in try block.


51.What are the limitations of OOPs?

Answer:

Limitation of OOPS:

1-designing is difficult.

2-slower execution

3-large in size

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Recent Comments