Advertisement
monoteen

1117_HW

Nov 16th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. class Info1 {
  2.    
  3.     String name;
  4.     int age;
  5.    
  6.     public Info1() {
  7.         name = "홍길동";
  8.         age = 21;
  9.     }
  10.    
  11.     public Info1(String str, int num) {
  12.         name = str;
  13.         age = num;
  14.     }
  15.    
  16.     public void prtInfo1() {
  17.         System.out.println("이름 : "+name);
  18.         System.out.println("나이 : "+age);
  19.     }
  20.    
  21. }
  22. public class InfoS extends Info1 {
  23.    
  24.     String add;
  25.    
  26.     public InfoS(String string, int i, String string2) {
  27.         super(string, i);
  28.         add = string2;
  29.     }
  30.  
  31.     public InfoS() {
  32.         super();
  33.     }
  34.  
  35.     public void prtInfo1() {
  36.         /*
  37.         System.out.println("이름 : "+name);
  38.         System.out.println("나이 : "+age);
  39.         */
  40.         super.prtInfo1();
  41.         System.out.println("주소 : "+add);
  42.     }
  43.  
  44.     public static void main(String[] args) {
  45.         InfoS obj1 = new InfoS();
  46.         obj1.name = "【=◈︿◈=】";
  47.         obj1.age = 34;
  48.         obj1.add = "경기도 이천시 마장면 해월리";
  49.         obj1.prtInfo1();
  50.        
  51.         InfoS obj2 = new InfoS("오승주", 20, "경기도 군포시");
  52.         obj2.prtInfo1();
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement