Advertisement
Guest User

Untitled

a guest
May 16th, 2019
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. public class Bird {
  2.     public String getName(){
  3.         return "Bird";
  4.     }
  5.  
  6.     public void displayInfo(){
  7.         System.out.println("The current type is: " + getName());
  8.     }
  9. }
  10.  
  11. public class Peacock extends Bird{
  12.     public String getName() {
  13.         return "Peacock";
  14.     }
  15. }
  16.  
  17. public static void main(String[] args) {
  18.     Bird bird = new Peacock();
  19.     bird.displayInfo();
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement