-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestConstruct.java
More file actions
41 lines (35 loc) · 844 Bytes
/
Copy pathTestConstruct.java
File metadata and controls
41 lines (35 loc) · 844 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
33
34
35
36
37
38
39
40
41
class Person2 {
private String name;
private String location;
Person2(String name) {
this.name = name;
location = "beijing";
}
Person2(String name,String location) {
this.name = name;
this.location = location;
}
public String info() {
return
"name: "+name+" location: "+location;
}
}
class Teacher extends Person2 {
private String capital;
Teacher(String name, String capital) {
this(name, "beijing", capital);
}
Teacher(String name, String location, String capital) {
super(name, location);
this.capital = capital;
}
public String info() {
return super.info() + "capital: " + capital;
}
}
public class TestConstruct {
public static void main(String[] args) {
Teacher t = new Teacher("B", "GG");
System.out.println(t.info());
}
}