Object-oriented programming concepts Part-2

The Java language is (mostly) object oriented. If you haven't used an object-oriented language before, OOP concepts might seem strange at first.

What is an object?


An object is a self-contained entity that contains attributes and behavior, and nothing more.
Example:

  • Attribute: What attributes can a person have? Some common ones include:
    • Name
    • Age
    • Height
    • Weight
    • Eye color
    • Gender
    • You can probably think of more (and you can always add more attributes later), but this list is a good start.

  • Behavior An actual person can do all sorts of things, but object behaviors usually relate to some kind of application context. 
    • What is your name?
    • What is your age?
    • What is your height?
    • What is your weight?
    • What is your eye color?
    • What is your gender?

What Is a Class?

In the real world, you'll often find many individual objects all of the same kind. There may be thousands of other bicycles in existence, all of the same make and model. Each bicycle was built from the same set of blueprints and therefore contains the same components. In object-oriented terms, we say that your bicycle is an instance of the class of objects known as bicycles. A class is the blueprint from which individual objects are created

An object is an instance of a class

The term ‘object’, however, refers to an actual instance of a class. Every object must belong to a class. Objects are created and eventually destroyed – so they only live in the program for a limited time. While objects are ‘living’ their properties may also be changed signficantly.

Object versus class


We can say, a class is a general concept (like an Animal), an object is a very specific embodiment of that class, with a limited lifespan (like a lion, cat, or a zebra). Another way of thinking about the difference between a class and an object is that a class provides a template for something more specific that the programmer has to define, which he/she will do when creating an object of that class.



Comments

  1. nice blog for selenium Training.,thanks for the info. Share more tutorials and if the readers want to have hands on training with real time scenarios...
    THE CREATING EXPERTS
    http://thecreatingexperts.com/selenium-training-in-chennai/
    contact 8122241286

    ReplyDelete

Post a Comment