Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions? | Software Development
 

Object

An object is the combination of related states and behavior in which variables are just like states and the methods are just like behaviors (providing some functionality).

Object

                         

An object is the combination of related states and behavior in which variables are just like states and the methods are just like behaviors (providing some functionality). In an object, variables store values for later use and methods are the unit of codes that provides a particular functionality. We can say objects are the basic units of the object-oriented programming.

Objects are the part of our day to day life, these are the real world entities around us. Technology, records, human beings, and even the implemented concepts all are the examples of objects. For instance, A CEO of any company can take a view of his company's policies, employees, buildings, records, and beneficial packages as the objects. Similarly a software developer does analysis, designing, coding, testing and also looks for the future scope of that project as objects. Even a toy is an object for a child. 

Real-world objects share two characteristics: They all have state and behavior. 

For instance Lions have state (name, color, breed, hungry) and behavior (roaring, fetching etc). Cars also have state (current gear, current speed) and behavior (changing gear, changing speed, applying brakes). Identifying the state and behavior for real-world objects is a great way to begin thinking in terms of object-oriented programming. Objects are key to understanding object-oriented programming. Just look around and you'll find a lot of examples of real-world objects: cat, desk, television set, car, pen etc.

Here is an additional information about Objects that we can create multiple objects in any single java application to perform many task like implementing a GUI, any operation on information and many more.

    Car myCar = new Car();

If we consider above example of car then if we need to create a new car, we have to make a new instance or an object by using the new keyword. The constructor is responsible for setting up the initial state of an object. Instead of declaring an object, a constructor is called automatically when the new keyword is used.

A simple example of constructing an object is given below:

Here is the Code of the Example :

Classtest.java

import java.lang.*;


public class Vehicle{

  public static void main(String args[])

    {
    Car myCar = new Car();

    myCar.display();

      }

  }

  class Car{

      public void display(){

        System.out.println("\nIt's a example of car");

      }

    }

Here is the Output of the Example :

C:\roseindia>javac Vehicle.java

C:\roseindia>java Vehicle

It's a example of car

Download This Example :

                         

» View all related tutorials
Related Tags: java programming orm form language io operators operator bitwise opera usage show for example bit program to ram exam lan

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.