-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.java
More file actions
82 lines (49 loc) · 1.32 KB
/
inheritance.java
File metadata and controls
82 lines (49 loc) · 1.32 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package class_programs;
import class_programs2.*; // importing from another package.
class joey extends chandler{
String c;
//sub class representing single inheritance
joey(int a ,int b,String c){
super(a,b);
this.c=c;
}
int show(){ //method overloading
super.show("joey");
return 0;
}
}
class monica extends joey{
String s;
int t;
monica(int a,int b,String c){
//sub class representing multi level inheritance.
super(a,b,c);
}
void show(int temp) { //method overloading
t=temp;
System.out.print("\nValues stored in the object of class monica: a= "+a+",b= "+b+",c= "+c);
}
}
class rachel extends chandler{
rachel(int a,int b){
super(a,b); //sub class representing hierarchial inheritance.
}
int show(){ //method overloading
super.show("rachel");
return 0;
}
}
public class inheritance {
public static void main(String[] args) {
System.out.println("This program is written by\nAshik MR, 4NI19IS017, B section");
chandler bing=new chandler();
bing.show("chandler");
joey tribbiani=new joey(22,69,"how you doin?");
tribbiani.show();
monica geller=new monica(77,777,"chef");
geller.show(10);
// geller.show();
rachel green =new rachel(44,11);
int t=green.show();
}
}