-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.java
More file actions
36 lines (23 loc) · 866 Bytes
/
inheritance.java
File metadata and controls
36 lines (23 loc) · 866 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
import java.util.Timer;
import shape.triangle;
//inheritance
//ek class kki poperties jab koi dusri class lena chahti hai, to us process ko kehte hai INHERITAMCE
//jis class se properties li jati hai - us class ki BASE class kehte hai;
//jo class properti leti hai - us class ko kehte hai CHILD class;
//>>>SINGLE LEVEL INHERITANCE<<<<
class shape {
public void area() {
System.out.println("display area");
}
}
class triangle extends shape { // triangle class ne shape ki properties ko extend kar liya //matlab inheritance
// kr liya
public void area(int l, int h) {
System.out.println(1 / 2 * l * h);
}
}
public class inheritance {
public static void main(String[] args) {
triangle t1 =new triangle();
}
}