Objects

Objects are the basic key to understand object-oriented programming. Programming objects are just like real-world objects. Look around, you'll see many objects. Your car, mobile phone, desk, laptop, pet dog, and DVD player are all objects.

All objects have two characteristics: properties and methods.

A mobile has properties (color, screen size, height, and weight) and methods (make calls, send SMSs, receive calls, and transfer files).

A car has properties (color, height, gearbox, wheels, engine, brakes, and steering) and methods (start engine, steer, change gear, apply brake, stop, and crash).

Just like these real-world examples, the objects in OOP have the same characteristics. So, an object, in terms of programming, can have properties (variables ...

Get Web Developer's Reference Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.