explain oops concepts with examples?

Answers were Sorted based on User's Feedback



explain oops concepts with examples?..

Answer / devendra.m

OOP concepts are mainly 4 parts
such as
1.Abstraction
2.Encapsulation
3.Inheritence
4.Polymorphism

1.Abstraction:which means showing essential features and
hiding non-essential features to the user.

for ex. yahoo mail...

when you provide the user name and password and click on
submit button..
it will shows comepose,Inbox,Outbox,sentmails...so and so
when you click on compose it will open...but user doesn't
know what are the actions performed internally....
just it is open only....this is essential
user doesn't know internall actions ...this is non-essential
things...

for ex tv remote..
remote is a interface between user and tv..ryt.
which is no.of buttons like 0 to 10 ,on /oof like that
but we dont know inside remote like circuites...
user no need to know..just he is using essential thing is
remote.
so developer of remote has to hide the circuit becz he
doesn't anything abut remote...this is non-essential thing.

2.Encapsulation: means which binds the data and code.
(or) writing operations and methods in single unit (class).

for example:
A car is having multipls parts..like
stering,wheels,engine...etc..which binds together to form a
single object that is car.

In real time we are using for security purpose...
encapsulation = abstraction + data hiding.

3.Inheritance:
Deriving a new class from the existing class,is
called inheritance

derived(sub class) class is getting all the features from
existing (super class) class and also incorporating some new
features to the sub class.

for ex:
class Address
{
String name;
Srting H.no;
String Street name;
}
class LatestAddress extends Address
{
String City;
String State;
String Country;
}
public class Devendra
{
psvm(----)
{
LatestAddress la = new LatestAddress();
//do assignment...as u wish
}
}

here in the above class LatestAddress getting all features
from the Address class.
here in the LatestAddress class is having total 6 properties
3 from inheited from Address class and 3 properties
incorporated.

4.Polymorphism:
poly means many

one form can perform differently in different scenarios.
(or) we can use multiful forms in multiful scenarios we will
get different results in different scenarios.

polymorphism mainly happens in runtime only..i.e in
overriding itself

for example
class A
{
void test()
{
sop("A");
}
void test1()
{
sop("A()");
}
}
class B extends A
{
void test()
{
sop("B");
}
void test1()
{
sop("B()");
}
void another()
{
sop("another()");
}
}
public class Devendra
{
psvm(---)
{
A a1 = new A();
A a2 = new B();
B b = new B();
a1.test();------> A
a1.test1();-----> A()
a2.test();------> A
a2.test1();-----> A()
b.test();-------> B
b.test1();------> B()
b.another();----> another()


If you have any quires pls mail me at mdevendra@gmail.com

Is This Answer Correct ?    48 Yes 15 No

explain oops concepts with examples?..

Answer / ravikiran

abstraction
encapsulation
inheritence
polymorphism

Is This Answer Correct ?    141 Yes 110 No

explain oops concepts with examples?..

Answer / manoj donga

OOP is Nothing but Object Oriented Programming.
In OOPs concept is implimented in our real life systems.
OOPs have following features
1. Object - Instance of class
2. Class - Blue print of Object
3. encapsulation - Protecting our data
4. polymorphism - Different behaviors at diff. instances
5. abstraction - Hidding our irrelavance data
6. inheritence - one property of object is aquring to
another property of object

Simple Ex.

Please assume u standing near a car. How to impliments our
OOPs concept for this scenario ?

Simple,
car is a object b'coz it having more functions.
car is a class b'coz it contain more parts and features
inside.
car is a Encapsulation B'coz it protected some unwanted
parts or functions to user
car is a Polymorphism b'coz it have different speed as
display in same speedometer
car is a Abstraction b'coz it hidding more parts by coverig
such as engine,disel tank
car is a Inheritance b'coz one car is a property of more
people. i mean your car is driving bu you, your friend and
your relatives.

Is This Answer Correct ?    26 Yes 8 No

explain oops concepts with examples?..

Answer / vaibhav pathak

OOP is Object Oriented Programming.
In OOPs concept is implimented in our real life systems.
OOPs have following features
1. Object - Instance of class
2. Class - Collection of Object(Methods and
variable)
3. encapsulation - Protecting our data by data hiding
encapsulation=abstraction+data hiding.
4. polymorphism - Different behaviors at diff. instances
5. abstraction - Hidding our irrelavance data and
showing necessary data to the user.
6. inheritence - one property of one object is aquring
by the another object.

Simple Ex.

Please assume u standing near a car. How to impliments our
OOPs concept for this scenario ?

Simple,
A motor bike is a object b'coz it having more functions.
motor bike is a class b'coz it contain more parts and
features
inside.
motor bike is a Encapsulation B'coz it protected some
unwanted
parts or functions to user
motor bike is a Polymorphism b'coz it have different speed
as
display in same speedometer
motor bike is a Abstraction b'coz it hidding more parts by
coverig
such as engine,disel tank
motor bike is a Inheritance b'coz one car is a property of
more
people. i mean your car is driving bu you, your friend and
your relatives.

Is This Answer Correct ?    25 Yes 7 No

explain oops concepts with examples?..

Answer / srinivas

abstraction:it shows important data and hide the unwanted data
polymorphism:it shows different behaviors at different instances
Encapsulation:it provides security for the data
inheritance:the process of acquiring the properties of one
object to another object

Is This Answer Correct ?    22 Yes 6 No

explain oops concepts with examples?..

Answer / surender dagar

oOP concepts are mainly 4 parts
such as
1.Abstraction
2.Encapsulation
3.Inheritence
4.Polymorphism

Is This Answer Correct ?    23 Yes 7 No

explain oops concepts with examples?..

Answer / nirmal kumar

Abstraction: is hiding irrelevant of data

object: Instance of class
class: Blue print of object

polymorphism: different function with different parameter

interface:is semantically related to abstract
members,members by public default.

Encapsulation: capsule with data and object
inheritance: Base class derived from another class

Is This Answer Correct ?    26 Yes 11 No

explain oops concepts with examples?..

Answer / mudassir shakil

1.Encapsulation-means wrapping or grouping data in single e
unit.
e.g. if you are planning to do computer course in a
institute but you don't know which course is going on in the
institute.But they have printed paper in which all the
courses are written like java,.net etc. This is called
encapsulation.
2.Abstraction-means hiding non essential information.
e.g.-Consider the above example.you have decided for java
the you enters in the institute and tell your course.The
person will explain you about java like duration;fee
structure etc.In simple words abstraction means information
according to the user.
3.Polymorphism-different existence.
e.g-you are a son,brother,uncle,husband and friend at
different situation.

Is This Answer Correct ?    16 Yes 5 No

explain oops concepts with examples?..

Answer / rajasekharareddy

* Objects
* Classes
* Inheritance
* Data Abstraction
* Data Encapsulation
* Polymorphism
* Overloading
* Reusability

In order to understand the basic concepts in C++, the
programmer must have a command of the basic terminology in
object-oriented programming. Below is a brief outline of the
concepts of Object-oriented programming languages:

Objects:

Object is the basic unit of object-oriented programming.
Objects are identified by its unique name. An object
represents a particular instance of a class. There can be
more than one instance of an object. Each instance of an
object can hold its own relevant data.


An Object is a collection of data members and associated
member functions also known as methods.

Classes:

Classes are data types based on which objects are created.
Objects with similar properties and methods are grouped
together to form a Class. Thus a Class represent a set of
individual objects. Characteristics of an object are
represented in a class as Properties. The actions that can
be performed by objects becomes functions of the class and
is referred to as Methods.

For example consider we have a Class of Cars under which
Santro Xing, Alto and WaganR represents individual Objects.
In this context each Car Object will have its own, Model,
Year of Manufacture, Colour, Top Speed, Engine Power etc.,
which form Properties of the Car class and the associated
actions i.e., object functions like Start, Move, Stop form
the Methods of Car Class.

No memory is allocated when a class is created. Memory is
allocated only when an object is created, i.e., when an
instance of a class is created.

Inheritance:

Inheritance is the process of forming a new class from an
existing class or base class. The base class is also known
as parent class or super class, The new class that is formed
is called derived class. Derived class is also known as a
child class or sub class. Inheritance helps in reducing the
overall code size of the program, which is an important
concept in object-oriented programming.

Data Abstraction:

Data Abstraction increases the power of programming language
by creating user defined data types. Data Abstraction also
represents the needed information in the program without
presenting the details.

Data Encapsulation:

Data Encapsulation combines data and functions into a single
unit called Class. When using Data Encapsulation, data is
not accessed directly; it is only accessible through the
functions present inside the class. Data Encapsulation
enables the important concept of data hiding possible.

Polymorphism:

Polymorphism allows routines to use variables of different
types at different times. An operator or function can be
given different meanings or functions. Polymorphism refers
to a single function or multi-functioning operator
performing in different ways.

Overloading:

Overloading is one type of Polymorphism. It allows an object
to have different meanings, depending on its context. When
an exiting operator or function begins to operate on new
data type, or class, it is understood to be overloaded.

Reusability:

This term refers to the ability for multiple programmers to
use the same written and debugged existing class of data.
This is a time saving device and adds code efficiency to the
language. Additionally, the programmer can incorporate new
features to the existing class, further developing the
application and allowing users to achieve increased
performance. This time saving feature optimizes code, helps
in gaining secured applications and facilitates easier
maintenance on the application.

The implementation of each of the above object-oriented
programming features for C++ will be highlighted in later
sections.

Is This Answer Correct ?    12 Yes 4 No

explain oops concepts with examples?..

Answer / palivela sri durgaprasad

there are type of oops concepts are there
1.objects/ class
1.Encapsulation
3.Abstraction
4.Polymorphism
5.Inheritance
6.Message passing
7.Dynamic binding

Is This Answer Correct ?    11 Yes 3 No

Post New Answer

More Core Java Interview Questions

What is the SimpleTimeZone class?

0 Answers  


Where are the card layouts used?

0 Answers  


Write a program to find the greatest of three numbers in java?

0 Answers  


What is meant by throwing an Exception?

4 Answers   Accenture,


Is there any tag in htm to upload and download files?

0 Answers  






What is the difference between pass by reference and pass by pointer?

0 Answers  


Can you explain inner class.

0 Answers  


What is casting?

3 Answers  


What is a subsequence of a string?

0 Answers  


Is singleton class thread safe?

0 Answers  


What is better - 'bit-shift a value' or 'multiply by 2'?

0 Answers   DELL,


How are Java source code files named?

3 Answers  


Categories