HarrJ

B5 Day 18 parent child

Aug 26th, 2022
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1.  
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         animalName callAnimalName = new animalName();
  5.         callAnimalName.animalAction();
  6.     }
  7. }
  8.  
  9. class animalName extends Animal {    
  10.     public void animalAction(){
  11.         System.out.println("____ actions:");
  12.         eating();
  13.         noise();
  14.         run();
  15.         sleep();
  16.     }
  17. }
  18.  
  19. class Animal {
  20.     public void eating() {
  21.         System.out.println("eating");
  22.     }
  23.    
  24.     public void noise() {
  25.         System.out.println("making sounds");
  26.     }
  27.    
  28.     public void sleep() {
  29.         System.out.println("sleeping");
  30.     }
  31.    
  32.     public void run() {
  33.         System.out.println("running on all four legs");
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment