22:39

Abstract class

Posted by Mitesh Patel |

/*
abstract class
 */

abstract class Vahicle {

    void number_of_tyres() {
    }
}

//child class
class car extends Vahicle {

    void number_of_tyres() {

        System.out.println("Tyres = 4");

    }
}

class Truck extends Vahicle {

    void number_of_tyres() {
        System.out.println("Tyres = 8");
    }
}

class scooter extends Vahicle {

    void number_of_tyres() {
        System.out.println("Tyres = 2");
    }
}

class AbstractClass {

    public static void main(String args[]) {

        Vahicle a = new scooter();
        a.number_of_tyres();

        a = new Truck();
        a.number_of_tyres();

    }
}

1 comments:

Unknown said...

you might visit here for more information:
http://usedvehiclesireland.com/

Post a Comment

Subscribe