Real world objects includes things like” your mobile phone, television, and washing machine etc. Each and every object has two important characteristic first one is the state/properties and the next one is their behavior/methods.
Example: A television has properties like its color and weight, and methods like on and off.
Note: Different television may have same properties, but the value of properties vary from television to television. Similarly different television may have same methods, but the performance of methods may be time dependent.
In the universe of softwares, objects are modelled after the real world objects. That means such objects also possess these two characteristic, states and behavior. In a programming language objects maintain its state and characteristics in terms of variables and methods respectively.
We already discussed about the variables in earlier tutorial. A variable is nothing but a place holder, that is used to hold a value. Just like a variable, an object is also used as a placeholder, but it has capability of holding more than one value.
Properties of an object can be any of the available data types, or any of the abstract data type like an another object. As we have already mentioned, the properties of an object are nothing but the variables, these variables are used internally in the methods of an object.
object_name.object_property = property_value;
// Object Creation var myTv = new object(); myTv.company = 'Samsung'; myTv.model = 'S-3826'; myTv.year = 2021;
Note: The object written above can also be written using an Object Initializer (the values of an object are written as a pair of name and value like: name:value (colon is used as a separator), each value is separated by comma separator).
In case you find any kind of error like typing error, spelling mistakes, incorrect grammar, incorrect information or any other mistakes. Please feel free to write to us at: firstname.lastname@example.org.