SHARE
TWEET

Untitled

a guest May 16th, 2019 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top