Advertisement
Guest User

Abstract

a guest
Nov 21st, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package pkgabstract;
  7.  
  8. /**
  9. *
  10. * @author Student
  11. */
  12. abstract class Animal {
  13. abstract void sound();
  14.  
  15. }
  16.  
  17. class Dog extends Animal {
  18. @Override
  19. public void sound() {
  20. System.out.println("Ghug Ghug");
  21. }
  22. }
  23.  
  24. class Cat extends Animal {
  25. @Override
  26. public void sound() {
  27. System.out.println("Meow ");
  28. }
  29. }
  30.  
  31.  
  32.  
  33. public class Abstract {
  34.  
  35. /**
  36. * @param args the command line arguments
  37. */
  38. public static void main(String[] args) {
  39. // TODO code application logic here
  40.  
  41. Dog d1 = new Dog();
  42. d1.sound();
  43.  
  44. Cat c1 = new Cat();
  45. c1.sound();
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement