GeekInterview.com
Series: Subject: Topic:
Question: 100 of 357

Explain OOPs,With real world examples

Asked by: Interview Candidate | Asked on: Aug 16th, 2006

Editorial / Best Answer

Answered by: Linto

Answered On : Aug 31st, 2006

OOPs is Object Oriented Programming.The great thing about OOPs is that is all about classes and objects which can easily correlated with real life scenarios.

Class is the general thing and object is the specilisation of general thing

For example if Human can be a class and linto ,raj etc are names of persons which can be considered as object.It supports concepts such as data abstation,inheritence ,polymorhpism etc.

Data Abstration is the  process of encapsulating data with in object so as to protect data and to avoid unwanted access(You know now the age of information explosion ,so giving proper data has greater significance)

So for our example every human has eye ,so eyecolor can be considered as the property of human being which can be encapsulted as a data in our class Human

class Human

{

private:

EyeColor IColor;

NAME personname;

};

Consider object of class of

Human myhuman;

we want set myhuman's name as "linto" and IColor as "black"

For that we want methods to do that task.

So need methods for class to do a particular task on the data

class Human

{

private:

EyeColor IColor;

NAME personname;

public:

void SetName(NAME anyName);

void SetIColor(EyeColor eyecolor);

};

So a class is a thing which has data members(normally properties of object) and methods to manipulate that data.But the thing to undersand is that class has propeties not any particular data.In other words the Human class no specific IColor.Only when one object of that class (myhuman) has name "linto" and IColor "black".

Next we can go through the concept of inheritence which has the same as the word meaning as u all aware.

           Human

             |

       ____|_____

       |              |

      /              /

   Men            Women

Here Human is general class and Man and Women are sub classes of general thing.That is Human  class contains all features general and Human and Women contains features specific to their own class.

Hey try to write class ...you will get the essence of OOPs.

   

   

Showing Answers 1 - 1 of 1 Answers
Linto

Answered On : Aug 31st, 2006

OOPs is Object Oriented Programming.The great thing about OOPs is that is all about classes and objects which can easily correlated with real life scenarios.Class is the general thing and object is the specilisation of general thingFor example if Human can be a class and linto ,raj etc are names of persons which can be considered as object.It supports concepts such as data abstation,inheritence ,polymorhpism etc. Data Abstration is the  process of encapsulating data with in object so as to protect data and to avoid unwanted access(You know now the age of information explosion ,so giving proper data has greater significance)So for our example every human has eye ,so eyecolor can be considered as the property of human being which can be encapsulted as a data in our class Humanclass Human{private:EyeColor IColor;NAME personname;};Consider object of class of Human myhuman;we want set myhuman's name as "linto" and IColor as "black"For that we want methods to do that task.So need methods for class to do a particular task on the dataclass Human{private:EyeColor IColor;NAME personname;public:void SetName(NAME anyName);void SetIColor(EyeColor eyecolor);};So a class is a thing which has data members(normally properties of object) and methods to manipulate that data.But the thing to undersand is that class has propeties not any particular data.In other words the Human class no specific IColor.Only when one object of that class (myhuman) has name "linto" and IColor "black".Next we can go through the concept of inheritence which has the same as the word meaning as u all aware.            Human             |       ____|_____       |              |      /              /   Men            WomenHere Human is general class and Man and Women are sub classes of general thing.That is Human  class contains all features general and Human and Women contains features specific to their own class.Hey try to write class ...you will get the essence of OOPs.       

Yes  6 Users have rated as useful.
  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.