Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Anatomy of objects and classes#

Sumit Rawal answered on March 3, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


Anatomy of objects and classes#

0

Objects may contain data in the form of fields (variables) and methods to operate on that data.

Think about real-world objects around you. What are the characteristics of these objects? Take the example of a light bulb. It has a state, which means that it is either on or off. It also has a behavior, which means that when it is turned on it lights up, and when it is turned off, it does not produce any light. To conclude this, one can say:

Objects are a collection of data and their behaviors.

But where do these objects come from?

The answer to the above question is classes.

A class can be thought of as a blueprint for creating objects.

The illustration below shows what a LightBulb class should look like:

1 of 3

From the above illustration, you can see that the state of the object is generally modeled using variables in a class, and the behavior is modeled using methods.

There can be many different objects of the same class. Each can be in an independent state, but all of them will share the same behavior and characteristics.

Popularity 1/10 Helpfulness 1/10 Language typescript
Source: Grepper
Tags: typescript
Link to this answer
Share Copy Link
Contributed on May 17 2023
Sumit Rawal
0 Answers  Avg Quality 2/10

Closely Related Answers



0
Popularity 2/10 Helpfulness 1/10 Language typescript
Source: Grepper
Link to this answer
Share Copy Link
Contributed on Mar 03 2023
Vinay Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.