0

What's the difference between method and property

methods and properties

7th Nov 2018, 11:56 AM
Adams Mujahid
Adams Mujahid - avatar
5 Réponses
+ 9
property is a value, method is a callable function
7th Nov 2018, 4:49 PM
Flandre Scarlet
Flandre Scarlet - avatar
+ 6
properties are your class members like private int age; private name; Methods are used for getting and setting private field values
7th Nov 2018, 12:30 PM
D_Stark
D_Stark - avatar
+ 6
ill try, Public String name; < this is called a field. Private int age; < this is also a field but has controlled access thorough using get and set. As your having to access the private field via a method this method is called the property which has the get and set inside the methods body.
7th Nov 2018, 1:57 PM
D_Stark
D_Stark - avatar
+ 2
Thanks D_Stark but I want know the the key difference between the two.
7th Nov 2018, 12:46 PM
Adams Mujahid
Adams Mujahid - avatar
+ 1
let's understand with practical example take class Human class Human { // first we declare property of human Int NoOfEar; int NoOfHand; int NoOfFingure; // now declare method of human Void Eat() void Sleep () void Walk () } so this the concept of property and methods.
11th Nov 2018, 1:09 PM
Vijay Makwana
Vijay Makwana - avatar