Print Friendly and PDF
OOP (Object Oriented Programing) and typesAn object is an entity that keeps together state and behaviors. For instance, a car encapsulates state such as red color, 900 cc etc and behaviors as 'Start', 'Stop' etc, so does an object. An object is an instance of a class. If you consider 'dog' as a class, it will contain all possible dog traits, while an object say a 'German Shepherd' contains characteristics of specific type of dog.
If you aspire to work in the field of IT, one of the most important concepts you are expected to know is OOP (Object Oriented Programming) . However, the technical interview can be nerve-wracking for even the most seasoned IT professional. To help you better prepare for just that, you need know how to present your answers in the best possible way, to impress the interviewer.Here's a look at some of the questions you should be prepared for.

~ What is OOP?

Object-oriented programming is commonly known as OOP. Most languages are developed using the OOP concept, 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 eg a motor bike. A bike performs actions such as 'start', 'stop' etc, and it has attributes like being red in colour, 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.

~ What are the various elements of OOP

Various elements of OOP are:

Object
Class
Method
Abstraction
Encapsulation
Information Hiding
Inheritance
Polymorphism

~ Explain an object.

An object is an entity that keeps together state and behaviors. For instance, a car encapsulates state such as red color, 900 cc etc and behaviors as 'Start', 'Stop' etc, so does an object.
An object is an instance of a class. If you consider 'dog' as a class, it will contain all possible dog traits, while an object say a 'German Shepherd' contains characteristics of specific type of dog.

~ Define a class.

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 behaviours. It is the blue print that describes objects.

~ What is Method?

Method is an object's behaviour. For instance if we assume 'dog' as an object then its behaviours are bark, walk, run etc.

~ Explain 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.

~ What is Information Hiding in OOP?

Information hiding concept restricts direct exposure of data. Data is accessed indirectly using safe mechanism, methods in case of programming object. Taking 'bike' as an example, we have no access to the piston directly but we can use the 'start button' to work the piston.

You can understand the advantage of the information hiding concept from this example. If a bike manufacturer allows direct access to piston, it would be very difficult to control the actual actions of the piston.

~ Define Inheritance.

The inheritance concept in OOP allows us to create a new class using an existing one. It also allows the new class to add its own functionality.

This concept can also be related to real world entity. A bike manufacturer uses the same mechanism of the existing version of the bike while launching a new version with some added functionalities.

This allows him to save time and effort.

~ Explain the term Polymorphism.

Polymorphism means the ability to take more than one form. An operation may exhibit different behaviours in different instances. The behaviour depends on the data types used in the operation.

~ What is Overloading Polymorphism?

Overloading allows multiple functions to exist with same name but different parameters. Again if you take bike as an example, it has a function 'Start' with two forms ie 'auto start' and 'kick start'.

~ Explain Overriding Polymorphism.

Overriding means changing behaviour of methods of base class in derive class by overriding the base class methods. If class A is a base class with method 'calculate' and class B inherits class A, thus derives method 'calculate' of class A. The behaviour of 'calculate' in class B can be changed by overriding it.

~ What are the advantages of OOP?

The following 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.
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: