You are on page 1of 4

Top 10 OOPs Interview Questions for TCS

28 September 2022 16:03

Ques 1. What is OOPS?


Ans: OOP is an abbreviation of object-oriented programming. It is a programming paradigm that
revolves around the object rather than function and procedure. In other words, it is an approach for
developing applications that emphasize on objects. An object is a real word entity that contains data and
code. It allows binding data and code together.

Ques 2. What are the various concepts in OOPS?


Ans: There are mainly 6 concepts in object oriented programming.
1. Class
2. Objects
3. Encapsulation
4. Data Abstraction
5. Polymorphism
6. Inheritance

Ques 3. What are the Features of OOPS?


Ans: There are 4 features of oops.
1. Encapsulation
2. Polymorphism
3. Abstraction
4. Inheritance

• Encapsulation: Encapsulation is a mechanism of wrapping the data members and member functions into
a single unit called class. It binds the data within a class, and no outside method can access the data.

• Polymorphism: Polymorphism consists of two words poly+morph, where poly means many and morphs
means many forms. So we can say one thing and multiple forms.
Polymorphism means having more than one function with the same name but with different
functionalities. Polymorphism is of two types:
1. Static polymorphism /early binding.
2. Dynamic polymorphism /late binding.

• Abstraction:
Abstraction is a technique of showing only essential details without representing the implementation details. If
the members are defined with a public keyword, then the members are accessible outside also. If the members
are defined with a private keyword, then the members are not accessible by the outside methods.

• Inheritance:
Inheritance provides reusability. Reusability means that one can use the functionalities of the existing class. It
eliminates the redundancy of code. Inheritance is a technique of deriving a new class from the old class. The
old class is known as the base class, and the new class is known as derived class.
Different Types of Inheritance
OOPs support the six different types of inheritance as given below :
1. Single inheritance
2. Multi-level inheritance
3. Multiple inheritance
4. Multipath inheritance
5. Hierarchical Inheritance
6. Hybrid Inheritance

Ques 4. What are the Advantages and Disadvantages of OOPS?


Ans:
Advantages of OOP
• It follows a bottom-up approach.
• It models the real word well.
• It allows us the reusability of code.
• Avoids unnecessary data exposure to the user by using the abstraction.
• OOP forces the designers to have a long and extensive design phase that results in better design and fewer
flaws.
• Decompose a complex problem into smaller chunks.
• Programmer are able to reach their goals faster.
• Minimizes the complexity.
• Easy redesign and extension of code that does not affect the other functionality.

Disadvantages of OOP
• Proper planning is required.
• Program design is tricky.
• Programmer should be well skilled.
• Classes tend to be overly generalized.

Ques 5. Difference between Structural and Object Oriented programming.


Ans:
Object-oriented Programming Structural Programming
It follows a bottom-up approach. It follows a top-down approach.
It provides data hiding. Data hiding is not allowed.
It is used to solve complex problems. It is used to solve moderate problems.
It allows reusability of code that reduces Reusability of code is not allowed.
redundancy of code.
It is based on objects rather than functions and It provides a logical structure to a program in which the program is
procedures. divided into functions.
It provides more security as it has a data hiding It provides less security as it does not support the data hiding feature.
feature.
More abstraction more flexibility. Less abstraction less flexibility.
It focuses on data. It focuses on the process or logical structure.
Ques 6. Pillars of OOPS
Ans: Refer answer 4

Ques 7. Difference between Encapsulation and Abstraction?


Ans:
Difference between Abstraction and Encapsulation:

Abstraction Encapsulation
• Abstraction is the process or method of gaining the • While encapsulation is the process or method to contain
information. the information.
• In abstraction, problems are solved at the design or • While in encapsulation, problems are solved at the
interface level. implementation level.
• Abstraction is the method of hiding the unwanted • Whereas encapsulation is a method to hide the data in a
information. single entity or unit along with a method to protect
information from outside.
• We can implement abstraction using abstract class • Whereas encapsulation can be implemented using by
and interfaces. access modifier i.e. private, protected and public.
• In abstraction, implementation complexities are • While in encapsulation, the data is hidden using methods
hidden using abstract classes and interfaces. of getters and setters.
• The objects that help to perform abstraction are • Whereas the objects that result in encapsulation need
encapsulated. not be abstracted.
• Abstraction provides access to specific part of data. • Encapsulation hides data and the user can not access
same directly (data hiding.
• Abstraction focus is on “what” should be done. • Encapsulation focus is on “How” it should be done.

Ques 8. Difference Between Compile time polymorphism and runtime polymorphism


Ans:
• Runtime polymorphism
Runtime polymorphism is also known as dynamic polymorphism. Function overriding is an example of
runtime polymorphism. Function overriding means when the child class contains the method which is
already present in the parent class. Hence, the child class overrides the method of the parent class. In case
of function overriding, parent and child class both contains the same function with the different definition.
The call to the function is determined at runtime is known as runtime polymorphism

• Compile time polymorphism


Compile-time polymorphism is also known as static polymorphism. The polymorphism which is
implemented at the compile time is known as compile-time polymorphism. Method overloading is an
example of compile-time polymorphism.

Ques 9. Difference between Class and Object?


Ans:
Class Object
It is a logical entity. It is a real-world entity.
It is conceptual. It is real.
It binds data and methods together into a single unit. It is just like a variable of a class.
It does not occupy space in the memory. It occupies space in the memory.
It is a data type that represents the blueprint of an object. It is an instance of the class.
It is declared once. Multiple objects can be declared as and when required.
It uses the keyword class when declared. It uses the new keyword to create an object.
A class can exist without any object. Objects cannot exist without a class.

Ques 10. Difference Between Constructor and Method?


Ans:

You might also like