what is object oriented programming?explain it with an example if possible | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is object oriented programming?explain it with an example if possible

2nd Aug 2016, 8:59 AM
Kalyan Surapaneni
Kalyan Surapaneni - avatar
4 Answers
+ 2
it is a programming concept whereby you use your own variables that contain more than one data type
4th Aug 2016, 4:14 PM
Ben Ntabo
Ben Ntabo - avatar
+ 1
I have a class, like a mug. It has some parameters, like dimensions, etc. If i create two instances of the class, even if they have the same parameters, are different objects. This is oop
12th Aug 2016, 7:06 PM
Matteo Sambruna
Matteo Sambruna - avatar
0
it s a programming concept that allow you to create a (variable ..the object ) that have multiple data fields with multiple values and this object come from a class
2nd Aug 2016, 10:57 PM
karim gomaa
karim gomaa - avatar
0
Object-Oriented Programming is very useful because you can create a single Class (or blueprint of data) that, from there, can initiate or instantiate numerous amounts of Objects (Class Instances) with their own identity, and certain attributes and values without having to rewrite the code for each object every single time it may be needed. Basically it allows for a blueprint type of programming where you can write/code one blueprint that can be used over and over to instantiate any amount of Objects needed from that Blueprint (or Class) which is very time saving and that is Object-Oriented Programming. So for example: I create a Class called Human Being. The "Class" is a blueprint for what a "Human Being" is in my program. So in the Class for Human Being I add data for Attributes and Behaviours (Variables and Methods) to define our objects. Giving them Attributes (Variables) such as Name, Age, Height, Weight, Sex, Hair Color, Eye Color, etc. And we also add data for Behaviour (Methods) which will be Run, Walk, Speak, Jump, Turn, etc. Now we have created a Class called Human Being that can be instantiated any amount of times as an Object (or Class Instances) with each Object having it's own identity and utilizing the Attributes and Behaviours that we originally programmed in the Class. So from the Class (blueprint) we only wrote/coded once, now we can make numerous Human Beings at any time we'd like to. Tall, skinny, 32 year old men with brown hair and brown eyes, or Short, chubby, 18 year old woman with blonde hair and blue eyes, and all of the created Humans are able to Speak, Jump, Turn, Run, Walk, etc. And we only had to program one big Class holding all of this data that is able to create Objects out of it. Hence Object-Oriented Programming. Hope this helps. :-)
26th Oct 2016, 5:44 AM
Sean Lindholm
Sean Lindholm - avatar