features of OOPS

Answer Posted / abhijit

Abstraction

Abstraction is a process of identifying the relevant
qualities and behvaiors an object should possess. Lets take
an example to understand abstraction. A Laptop consists of
many things such as processor, motherboard, RAM, keyboard,
LCD screen, wireless antena, web camera, usb ports, battery,
speakers etc. To use it, you don't need to know how
internally LCD screens, keyboard, web camera, battery,
wireless antena, speakers works. You just need to know how
to operate the laptop by switching it on. The intrinsic
details are invisitble. Think about if you would have to
call to the engineer who knows all internal details of the
laptop before operating it. This would have highly expensive
as well as not easy to use everywhere by everyone. So here
the Laptop is an object that is designed to hide its
complexity.

Think If you need to write a piece of software to track the
students details of a school, you may probably need to
create Students objects. People comes in all different
backgrounds, educational qualifications, locations, hobbies,
ages and have multiple religion, language but in terms of
application, an student is just a name, age, class and roll
number, while the other qualities are not relevant to the
application. Determining what other qualities (background,
qualifications, location, hobbiels etc) are in terms of this
application is abstraction.

In object-oriented software, complexity is managed by using
abstraction. Abstraction is a process that involves
identifying the critical behavior of an object and
eliminating irrelevant and complex detilals. A well
thought-out abstraction is usually simple, and easy to use
in the perspective of the user, the person who is using your
object.

Encapsulation

Encapsulation is a method for protecting data from unwanted
access or alteration by packaging it in an object where it
is only accessible through the object's interface.
Encapsulation are often referred to as information hiding.
But both are different. Infact information hiding is
actually the result of Encapsulation. Encapsulation makes it
possible to separate an object's implementation from its
orgiinal behavior - to restrict access of its internal data.
This restriction facilitate certains detiails of an object;s
behavior to be hidden. This allows to protect an object's
interal state from corruption by its user.

It is the mechanism by which Abstraction is implemented. In
other words you can say that it is the result of the
Encapsulation. For example, the Laptop is an object that
encapsulates many technologies/hardwares that might not be
understood clearly by most people who use it.
Inheritence

Inheritecne is the ability to define a new class or object
that inherits the behavior and its functionality of an
existing class. The new class or obejct is called a child or
subclass or derived class whie the original class is called
parent or base class. For example, in a software company
Software Engineers, Sr. Software Engineers, Module Lead,
Technical Lead, Project Lead, Project Manger, Program
Manger, Directors all are the employees of the the compnay
but their work, perks, roles, responsiblitues differs. So in
OOP, the Employee base class would provide the common
behaviours of all types/level of of employee and also some
behaviors properties that all employee must have for that
company. The particular sub class or child class of the
employee would impelement behaviors specific to that level
of the employee. So by above example you can notice that the
main concept behind inhertience are extensibility and code
reuse (in this case you are extending the Employee class and
using its code into sub class or derived class).
Polymorphism

As name suggests, Polymorphism means an ability to assume
different forms at different places. In OOP, it is a
language's ability to handle objects differently based on
their runtime type and use. Polymorphism is briefly
described as "one interface, many
implementations".Ppolymorphism is a characteristic of being
able to assign a different meaning or usage to something in
different contexts - specifically, to allow an entity such
as a variable, a function, or an object to have more than
one form.

There are two types of polymorphism.

1. Compile time polymorphism - It is achieved by
overloading functions and operators
2. Run time polymorphism - It is achieved by overriding
virtual functions

Lets say you have a class that have many Load methods having
different parameters, this is called Compile time
polymorphism. Lets take another example where you have a
virtual method in the base class called Load with one
parameter and you have redefined its functioanlity in your
sub class by overriding base class Load method, this is
called Run time polymorphism.

Is This Answer Correct ?    15 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an advantage of polymorphism?

585


What are the advantages of polymorphism?

570


Why do pointers exist?

653


What is polymorphism explain?

677


Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.

2567






write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).

1636


What is encapsulation in simple terms?

534


Why is destructor used?

576


How Do you Code Composition and Aggregation in C++ ?

24185


What is interface? When and where is it used?

1658


What is overloading in oop?

568


Describe these concepts: Polymorphism, Inheritance and Abstraction.

604


How do you define a class in oop?

620


Write a c++ program to display pass and fail for three student using static member function

2804


write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory

2750