Thursday, 13 August 2015

Java Tutorial : What is an Object?

Master Java with Us!

Enjoying this guide? Subscribe to Ram N Java for straightforward, beginner-friendly programming tutorials!

Subscribe on YouTube

What is an Object in Java? Real-World Examples Explained

Objects are the absolute key to understanding Object-Oriented Programming (OOP) technology. If you look around you right now, you will spot countless examples of real-world objects: your desk, your television set, your bicycle, a lamp, or your pet dog. In software development, Java models these real-world entities into digital objects.

1. The Two Core Characteristics of Any Object

Every real-world object and software object shares two primary characteristics:

  • State: The properties, attributes, or data representing the current condition of the object.
  • Behavior: The actions, operations, or tasks that the object can perform.

2. Real-World Object Examples

To understand how state and behavior map together, let's explore three simple examples:

  • Dog:
    • States: Name, color, breed, hungry.
    • Behaviors: Barking, fetching, wagging tail.
  • Desk Lamp:
    • States: On, off.
    • Behaviors: Turn on, turn off.
  • Bicycle:
    • States: Current gear, current cadence, current speed.
    • Behaviors: Changing gear, changing cadence, applying brakes.

3. How Java Represents Objects in Code

Software objects are conceptually identical to real-world objects:

  • An object stores its state in fields (also known as variables).
  • An object exposes its behavior through methods (functions).

Methods operate directly on an object's internal state and serve as the primary mechanism for objects to communicate with one another.

4. Data Encapsulation in OOP

Hiding an object's internal state and requiring all interactions to be performed cleanly through its methods is known as Data Encapsulation. This is one of the most fundamental principles in object-oriented software engineering.


Watch More Java Tutorials from Ram N Java


Click here to watch in Youtube :
https://www.youtube.com/watch?v=JIjKb-4srFY&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : What is an Object? 
Java Tutorial : What is an Object? 
Java Tutorial : What is an Object? 
See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment

    Tutorials