-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInheritence.java
60 lines (47 loc) · 999 Bytes
/
Inheritence.java
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
55
56
57
// Single Inheritence :-
//class one {
// public void print_Hello()
// {
// System.out.println("Hello,");
// }
//}
//
//class two extends one {
// public void print_for() { System.out.println("Mr.Vipul"); }
//}
//// Driver class
//public class Inheritence {
// public static void main(String[] args)
// {
// two g = new two();
// g.print_Hello();
// g.print_for();
// }
//}
//Multilevel Inheritence :-
class one {
public void print_hello()
{
System.out.print("Hello,");
}
}
class two extends one {
public void print_name() { System.out.print("Mr.Vipul "); }
}
class three extends two {
public void print_surName()
{
System.out.println("Upadhyay");
}
}
// Drived class
public class Inheritence {
public static void main(String[] args)
{
three g = new three();
g.print_hello();
g.print_name();
g.print_surName();
}
}
// Hierarchical Inheritance :-