Can any one help me to understand .. function,object and method. I am getting confuse. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can any one help me to understand .. function,object and method. I am getting confuse.

7th Apr 2020, 7:03 AM
Vikas(Vikasrastic)
Vikas(Vikasrastic) - avatar
3 Answers
+ 1
An object is an instance of a clases... A variable Of a clases type Methods are functions that your objects can execute... Functions are independent code blocks that can be summon On your program... (Tell me what language do you refeer and I Will explain with examples)
7th Apr 2020, 7:13 AM
V=IR
V=IR - avatar
+ 1
Functions are subprogram in a program. They are designed to avoid code repetition: if you repeat many times a same operation (ie: compute mean of two numbers), you could define a function wich do this specific task... As program in shell (linux bash, dos terminal...), they are able to receive arguments as input, run with or without side effects (ie: modifying other data, display state...) then could return a result. Objects are encapsulation of data + logic: for a value in a variable (ie: a price) as the developer and human analysis capable you know its purpose, but computers doesn't, even not if the value should be treated as number, char, or anything else, until you specify it (or engine in hi-level languages -- often interpreted ones). So objects are data structures storing collections of values (variables, or 'properties' or 'attributes' in this context), and/or dedicated logic: code, (sub)program (functions, or 'methods' in this context). Ex: object Disc with center, radius values and area method.
7th Apr 2020, 8:57 AM
visph
visph - avatar
+ 1
Thank you every one
11th Apr 2020, 6:18 AM
Vikas(Vikasrastic)
Vikas(Vikasrastic) - avatar