-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTut19.java
More file actions
54 lines (38 loc) · 1.02 KB
/
Tut19.java
File metadata and controls
54 lines (38 loc) · 1.02 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
package tutorial;
//Inheritance this is single inheritance
class College {
public College() {
System.out.println("College Constructor with empty");
}
public College(int x) {
System.out.println("College Constructor with value of x : " + x);
}
public void Supercalledmethod() {
System.out.println("This method has been called with the help of super");
}
}
//single inheritance
class Student3 extends College {
public Student3() {
super.Supercalledmethod(); // calling the college class method
System.out.println("Student Constructor with empty");
}
public Student3(int x) {
super(x); // calling the constructor of college class with x parameter
System.out.println("Student Constructor with value of x :" + x);
}
}
// this is multilevel inheritance
class Faculty extends Student3 {
}
//hierarchial inheritance
class details extends College {
}
class teacher extends College {
}
public class Tut19 {
public static void main(String[] args) {
Student3 st = new Student3();
st.Supercalledmethod();
}
}