Wednesday, February 20, 2008

Class Abstract

Abstract

abstract class LivingThing { //class abstract

public void eat() {

System.out.println("Living Thing eating...");

}

public void breath() {

System.out.println("Living Thing breathing...");

}

public abstract void walk(); //method abstract

}

class Dog extends LivingThing {

public void walk() {

System.out.println("Dog Walk ...");

}

}

class Human extends LivingThing {

public void walk() {

System.out.println("Human Walk ...");

}

}

public class Abstrak {

public static void main(String[] args) {

Human human = new Human();

human.breath();

human.eat();

human.walk();

Dog dog = new Dog();

dog.breath();

dog.eat();

dog.walk();

}

}

No comments: