- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChapter20.java
More file actions
Latest commit
31 lines (26 loc) · 720 Bytes
/
Copy pathChapter20.java
File metadata and controls
31 lines (26 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
packagechapter20;
classParent{
intnumber = 3;
Parent(){//기본 생성자
System.out.println("부모 객체 생성");
}
}
//상속 클래스
classChildextendsParent{
//int number = 2;
Child(){//기본 생성자
System.out.println("자식 객체 생성");
}
voidprint() {
intnumber = 1;
System.out.println(number);//함수내에서만 사용되는 지역변수 number
System.out.println(this.number);//자신 객체의 number
System.out.println(super.number);//부모 객체의 number
}
}
publicclassSuperEx {
publicstaticvoidmain(String[] args) {
Childchild = newChild();
child.print();
}
}