Write a Java program for abstract class and abstract method.
abstract class LivingThing {
public void breath() { //Concrete method
System.out.println("Living Thing breathing...");
}
public void eat() {
System.out.println("Living Thing eating...");
}
/**
* Abstract method walk()
* We want this method to be implemented by a
* Concrete class.
*/
public abstract void walk();
}
public class Human extends LivingThing
{
public void walk() {
System.out.println("Human walks...");
}
public static void main(String[] args) {
System.out.println("Hello from main");
Human h = new Human();
h.breath();
h.eat();
h.walk();
}
}
Hello from main
Living Thing breathing...
Living Thing eating...
Human walks...