-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJPR24.java
More file actions
126 lines (106 loc) · 2.71 KB
/
JPR24.java
File metadata and controls
126 lines (106 loc) · 2.71 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.google;
/*
Author: Vaibhavi Dixit
code for demonstrate inheritance
* */
// super class Google
class Google{
static String company="Google";
int noOfEmployees=90000;
void print(){
System.out.println("Welcome to "+company);
System.out.println("We have "+noOfEmployees+" no of employees.");
}
void work(){
System.out.println("We are working in Google");
}
}
/*
Single inheritance
Super class-Google
child class- Development*/
class Development extends Google{
int noOfEmployees=8000;
void print(){
System.out.println("We have "+noOfEmployees+" no of employees in development department.");
}
void work(){
System.out.println("We are working in development department of "+company);
}
}
/*
hierarchical inheritance
Super class-Google
child class- Design*/
class Design extends Google{
int noOfEmployees=12000;
void print(){
System.out.println("We have "+noOfEmployees+" no of employees in design department.");
}
void work(){
System.out.println("We are working in design department of "+company);
}
}
/*
multilevel inheritance
first super class-Google
Second Super class-Design
child class- Testing */
class Testing extends Design{
int noOfEmployees=19000;
void print(){
System.out.println("We have "+noOfEmployees+" no of employees in testing department.");
}
void work(){
System.out.println("We are working in testing department of "+company);
}
}
/*
single inheritance
Super class-Google
child class- Sales*/
class Sales extends Google{
int noOfEmployees=18000;
void print(){
System.out.println("We have "+noOfEmployees+" no of employees in sales department.");
}
void work(){
System.out.println("We are working in sales department of "+company);
}
}
/*
multilevel inheritance
first Super class-Google
second super class- Sales
child class- Account*/
class Account extends Sales{
int noOfEmployees=38000;
void print(){
System.out.println("We have "+noOfEmployees+" no of employees in account department.");
}
void work(){
System.out.println("We are working in account department of "+company);
}
}
public class JPR24 {
public static void main(String[] args) {
Google g1=new Google();
g1.print();
g1.work();
Development d1=new Development();
d1.work();
d1.print();
Design ds=new Design();
ds.print();
ds.work();
Testing t1= new Testing();
t1.print();
t1.work();
Sales s1=new Sales();
s1.print();
s1.work();
Account ac=new Account();
ac.work();
ac.print();
}
}