Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Bird {
- public String getName(){
- return "Bird";
- }
- public void displayInfo(){
- System.out.println("The current type is: " + getName());
- }
- }
- public class Peacock extends Bird{
- public String getName() {
- return "Peacock";
- }
- }
- public static void main(String[] args) {
- Bird bird = new Peacock();
- bird.displayInfo();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement