-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestSuperSub.java
More file actions
33 lines (28 loc) · 579 Bytes
/
TestSuperSub.java
File metadata and controls
33 lines (28 loc) · 579 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
32
package java04;
public class TestSuperSub {
public static void main(String[] args){
SubClass sc = new SubClass();
SubClass sc2 = new SubClass(1000);
}
}
class SuperClass{
private int n;
SuperClass(){
System.out.println("父类的无参数函数");
}
SuperClass(int n){
System.out.println("父类的有参数函数"+n);
this.n = n;
}
}
class SubClass extends SuperClass{
private int n;
SubClass(){
super(300);
System.out.println("子类的无参数函数");
}
SubClass(int n){
System.out.println("子类的又参数函数"+n);
this.n = n;
}
}