/** * @author lautturi.com * Java example: class method overriding in java */ import java.util.*; class Human { // Overridden method public void run() { System.out.println("hunman is running"); } } class Boy extends Human { // Overriding method public void run() { System.out.println("the boy is running"); } public static void main(String args[]) { } } public class Lautturi { public static void main(String[] args) { Boy boy = new Boy(); boy.run(); } }
output:
the boy is running