×

Html & Html5

The World's best Software Development Study Portal

Overriding

Subclass or child class provide a specific implementation of a method that is already provided, by one of its super- classes or parent classes .When subclass have the same name ,same parameters and same return type method of super–class method is called Overriding.

Example

class Birdss {

public void fly(){System.out.println("Flying.... ");

}

}

class Peacock extends Birdss{

public void dance(){System.out.println("Dancing.. ");

}

public void fly(){System.out.println("Peacock....");

}

}

public class Birds{

public static void main(String [] args){

Birdss f = new Peacock();

f.fly();

}

};

Output: