Objects

We assume now you are very much familiar with data types, variables, class { } & methods ( ). Object is the most important concept in Java.

So what is an object?

An object can be anything physical entity like dog, mobile, bike, fan etc. They are objects because they have a state and a behavior.

Example Dog object has

  • State: color, breed, age.
  • Behavior: sleep( ), bark( ), hungry( ).

JavaObjects

Example Mobile object has

  • State: color, brand.
  • Behavior: brandName( ), call( ), sms( ), price( ).

If you compare the software object with a real-world object, they have very similar characteristics. Here we have fields (similar to state or variables) and methods (similar to behavior).

Here you will understand what we are talking about:

Java Objects methods behaviors fields

Objects also has one more feature apart from behavior, state and that is Identity.

Identity: Object identity is typically implemented via a unique ID. The value of the ID is not visible to the external user. But, remember it is used internally by the JVM to identify each object uniquely. So, don’t bother about it.

So, what is an Object?

  • It is a real-world entity.
  • It is an instance(an example) of class.
  • It can be physical or logical thing.
  • It is an entity which has state (fields) and behavior (methods).

Now, you can relate this with the classes definition which you had learnt earlier in  class tutorial.

We know you didn’t got much about objects. You may have questions – Why Objects? What’s its use? But we promise that you will understand – What is the need of objects and its significance in next tutorial i.e in objects behavior. We will also learn how to make instance of a class i.e. objects.

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s