Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public class Main{
  2. public static void main(String[] args){
  3. General gen = new General();
  4. System.out.println(gen.currentDate());
  5. System.out.println(gen.name());
  6. System.out.println(gen.doMath());
  7.  
  8. General gen2 = new Specification();
  9. System.out.println(gen2.currentDate());
  10.  
  11. System.out.println(gen2.name());
  12.  
  13. System.out.println(gen2.doMath());
  14.  
  15. }
  16. }
  17.  
  18. class General{
  19. Date currentDate(){
  20. return new Date;
  21. }
  22.  
  23. String name(){
  24. return "Вася";
  25. }
  26.  
  27. double doMath(){
  28. return 2+2;
  29. }
  30. }
  31.  
  32.  
  33. class Specification extends General{
  34. String name(){
  35. return "Петя";
  36. }
  37. double doMath(){
  38. return Math.PI;
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement