View RSS Feed

Core Java

Java Classes

Rate this Entry
by , 03-02-2012 at 05:10 PM (711 Views)
Various individual objects might be found of same kind, in real work. Thousands of similar bicycles might be present in world that have similar model or make. Same components or same blueprints set are used to build bicycles.

Bicycle may be considered as class bicycle instance, in case of the object oriented programming. Class is basically the blue print which is involved in creation of the individual objects.

This given Bicycle class is the possible bicycle implementation:
Java Code: This is the code to explain Java Classes
class Bicycle {

    int cadence = 0;
    int speed = 0;
    int gear = 1;

    void changeCadence(int newValue) {
         cadence = newValue;

    void changeGear(int newValue) {
         gear = newValue;

    void speedUp(int increment) {
         speed = speed + increment;   

    void applyBrakes(int decrement) {
         speed = speed - decrement;

    void printStates() {
         System.out.println("cadence:" +
             cadence + " speed:" + 
             speed + " gear:" + gear);

Submit "Java Classes" to Facebook Submit "Java Classes" to Digg Submit "Java Classes" to Submit "Java Classes" to StumbleUpon Submit "Java Classes" to Google

Tags: java classes Add / Edit Tags