Tuesday, June 7, 2011

Let's start with an Object

Object in the world of Java programming language is instance of rules and behaviors specified by a Java Class. Class is what a programmer writes. It has definitions of state variables and behavior methods which various external entities can realize on the instances.

Object is something that can be realized at runtime. Let's leave this text aside and dive into an example -

Class SimpleCar{
protected Engine e;
protected Brake b;
protected Wheel[] w;
.
.
.
public void start(){
// Wake up
// .... code to start
}

public void accelerate(){
// Come on ... catch the rat
// .... code to accelerate
}

public void brake(){
// calm down my dear
// code to apply brakes
}

}


The code above depicts a Simple Car. This is what a class looks like. It defines the composition and behavior of a car. To be continued ...

No comments:

Post a Comment