Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

explain oops concepts with examples?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many types of array are there?

1013


Can a set contain duplicates?

955


What is string builder in java?

1023


What is a function easy definition?

1017


What is java oops?

1094


Why Do I Get A "permission Denied" Error After Downloading The .jnlp Java Launcher For The Vkvm?

1149


Are arrays static in java?

1065


You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain

996


How do you compare two strings lexicographically?

937


Why java is call by value?

1036


What is string data?

988


Discuss different types of errors that generally occur while programming.

1042


What is arraylist e in java?

1065


I am a fresher and know core java, c languge, html, css etc if I am illegible for any job then send it on my email tatranakshay276@gmail.com

1701


How do you declare an array that will hold more than 64KB of data?

1300