Enter your email address:

    Delivered by FeedBurner

Program Inheritance In Java


class Transportation {

String x="Transportation Equipment";

void ShowFunctionTransportation() {

System.out.println("Function transportation : " + x);

}

}



class TransportationLand extends Transportation {

String land="in the land";

void ShowFunctionTransportationLand() {

System.out.println("Function transportation in land :" + (x+land));

}

}

class TransportationWater extends Transportation {

String water="in the water";

void ShowFunctionTransportationWater() {

System.out.println("Function transportation in water :" + (x+water));

}

}

class TransportationAir extends Transportation {

String air="in the air";

void ShowFunctionTransportationAir() {

System.out.println("Function transportation in air :" + (x+air));

}

}

class bus extends TransportationLand {

String varbus="transportation with four wheels";

void ShowFunctionBus() {

System.out.println("Function bus :" + (x+land+varbus));

}

}

class bicycle extends TransportationLand {

String varbicycle="Transportation with two wheels";

void ShowFunctionBicycle() {

System.out.println("Function bicycle :" + (x+land+varbicycle));

}

}

class dogcart extends TransportationLand {

String vardogcart="using horse";

void ShowFunctionDogchart() {

System.out.println("Function dogcart :" + (x+land+vardogcart));

}

}

class boat extends TransportationWater {

String varboat=" to look for fish";

void ShowFunctionBoat() {

System.out.println("Function boat :" + (x+water+varboat));

}

}

class plane extends TransportationAir {

String varplane=" vehicle of appliance ";

void ShowFunctionPlane() {

System.out.println("Function plane :" + (x+air+varplane));

}

}

class Inheritance {

public static void main(String[] args) {

Transportation superx = new Transportation();

TransportationLand subxa = new TransportationLand();

TransportationWater subxb = new TransportationWater();

TransportationAir subxc = new TransportationAir();

bus sublanda = new bus();

bicycle sublandb = new bicycle();

dogchart sublandc = new dogchart();

boat subwater = new boat();

plane subair = new plane();

System.out.println("SuperClass");

superx.ShowFunctionTransportation();

System.out.println("SubClass Transportation");

subxa.ShowFunctionTransportationLand();

subxb.ShowFunctionTransportationWater();

subxc.ShowFunctionTransportationAir();

System.out.println("SubClass Transportation’s Land");

sublanda.ShowFunctionBus();

sublandb.ShowFunctionBicycle();

sublandc.ShowFunctionDogchart();

System.out.println("SubClass Transportation’s Water");

subwater.ShowFunctionBoat();

System.out.println("SubClass Transportation’s Air");

subair.ShowFunctionPlane();

}

}


By : Asep Herman Suyanto


class Transportation {

String x="Transportation Equipment";

void ShowFunctionTransportation() {

System.out.println("Function transportation : " + x);

}

}



class TransportationLand extends Transportation {

String land="in the land";

void ShowFunctionTransportationLand() {

System.out.println("Function transportation in land :" + (x+land));

}

}

class TransportationWater extends Transportation {

String water="in the water";

void ShowFunctionTransportationWater() {

System.out.println("Function transportation in water :" + (x+water));

}

}

class TransportationAir extends Transportation {

String air="in the air";

void ShowFunctionTransportationAir() {

System.out.println("Function transportation in air :" + (x+air));

}

}

class bus extends TransportationLand {

String varbus="transportation with four wheels";

void ShowFunctionBus() {

System.out.println("Function bus :" + (x+land+varbus));

}

}

class bicycle extends TransportationLand {

String varbicycle="Transportation with two wheels";

void ShowFunctionBicycle() {

System.out.println("Function bicycle :" + (x+land+varbicycle));

}

}

class dogcart extends TransportationLand {

String vardogcart="using horse";

void ShowFunctionDogchart() {

System.out.println("Function dogcart :" + (x+land+vardogcart));

}

}

class boat extends TransportationWater {

String varboat=" to look for fish";

void ShowFunctionBoat() {

System.out.println("Function boat :" + (x+water+varboat));

}

}

class plane extends TransportationAir {

String varplane=" vehicle of appliance ";

void ShowFunctionPlane() {

System.out.println("Function plane :" + (x+air+varplane));

}

}

class Inheritance {

public static void main(String[] args) {

Transportation superx = new Transportation();

TransportationLand subxa = new TransportationLand();

TransportationWater subxb = new TransportationWater();

TransportationAir subxc = new TransportationAir();

bus sublanda = new bus();

bicycle sublandb = new bicycle();

dogchart sublandc = new dogchart();

boat subwater = new boat();

plane subair = new plane();

System.out.println("SuperClass");

superx.ShowFunctionTransportation();

System.out.println("SubClass Transportation");

subxa.ShowFunctionTransportationLand();

subxb.ShowFunctionTransportationWater();

subxc.ShowFunctionTransportationAir();

System.out.println("SubClass Transportation’s Land");

sublanda.ShowFunctionBus();

sublandb.ShowFunctionBicycle();

sublandc.ShowFunctionDogchart();

System.out.println("SubClass Transportation’s Water");

subwater.ShowFunctionBoat();

System.out.println("SubClass Transportation’s Air");

subair.ShowFunctionPlane();

}

}


By : Asep Herman Suyanto


Recent Articles

Blog Archive