Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- // main class
- class Birds {
- String color;
- double size;
- String name;
- double weight;
- void Flying(){
- System.out.println("I can fly");
- }
- void Breathing(){
- System.out.println("I can breath");
- }
- void Eating(){
- System.out.println("I can eat");
- }
- void Reproducing(){
- System.out.println("I can reproduce");
- }
- }
- // subclass inherit from Birds
- class Eagle extends Birds{
- String sharpClaws;
- void hovering(){
- System.out.println("I can hover");
- }
- }
- // subclass inherit from Birds
- public class Parrot extends Birds{
- String curvedBeak;
- void talking(){
- System.out.println("I can talk");
- }
- public static void main(String[] args) {
- Parrot cuckatoos = new Parrot();
- cuckatoos.color = "Green";
- cuckatoos.Eating();
- cuckatoos.Reproducing();
- Eagle goldenEagle = new Eagle();
- goldenEagle.color = "gold";
- goldenEagle.Breathing();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement