Home |
Write |
147 members |

Join with Aptibook

OOP (Object oriented programming) interview questions and answers - Page 1

1. What is OOP?

The object oriented programming is commonly known as OOP. Most of the languages are developed using OOP concept. Object-oriented programming (OOP) is a programming concept that uses "objects" to develop a system.

A programming object has an ability to perform actions and has attributes. It performs just like real world entities for e.g. a motor bike. A bike performs actions such as ’Start’, ’Stop’ etc., and it has attributes like red color, 150 cc etc. So does an Object. Actions and attributes are represented by Methods and fields or properties respectively in programming language.

An object hides the implementation details and exposes only the functionalities and parameters it requires to its client. Here also an object shares the same concept as that of a bike. While driving a motor bike, we are unaware of its implementation details such as how it is developed, internal working of gears etc.? We know only the functions or actions it can perform.

2. What are the advantages of OOP?

• It presents a simple, clear and easy to maintain structure.
• It enhances program modularity since each object exists independently.
• New features can be easily added without disturbing the existing one.
• Objects can be reused in other program.

3. What is Abstraction in OOP ?

Abstraction is a process of identifying the essential details to be known and ignoring the non-essential details from the perspective of the end user.

The driver of a car needs to know how to apply brake, change gear and balance the steering. The driver need not know how the engine works

More info:
Structured Programming also supported abstraction with the help of data structures and functions. OOP provides better abstraction. While structured programming provides abstraction at the level of data structures and function, OOP provides abstraction at a higher level. Higher the abstraction level easier it is to understand.

4. Define a class in OOP

A class represents description of objects that share same attributes and actions. It defines the characteristics of the objects such as attributes and actions or behaviors. It is the blue print that describes objects.

5. Encapsulation concept in OOP

Encapsulation means keeping actions and attributes together under a single unit. This can also be understood using a motor bike example. A bike has actions such as ’switch on light’, ’horn’ etc. and attributes such specific color, size, weight etc. Here the actions and attributes are bundled together under a single unit, bike.

In a programming language, methods and properties that correspond to actions and attributes respectively are kept under a unit called object.

The advantage of encapsulation is that the implementation is not accessible to the client. The user has to know only the functionality of encapsulated unit and information to be supplied to get the result.