Skip to content

Commit 20cc4ad

Browse files
Inheritance in java
1 parent 2854974 commit 20cc4ad

File tree

10 files changed

+44
-0
lines changed

10 files changed

+44
-0
lines changed
828 Bytes
Binary file not shown.
350 Bytes
Binary file not shown.
343 Bytes
Binary file not shown.
350 Bytes
Binary file not shown.

inheritance/bin/module-info.class

150 Bytes
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package inheritance;
2+
3+
public class Class1 {
4+
5+
public static void main(String[] args) {
6+
square obj1 = new square();
7+
retangle obj2 = new retangle();
8+
triangle obj3 = new triangle();
9+
10+
System.out.println(obj1.getarea());
11+
System.out.println(obj2.getarea());
12+
System.out.println(obj3.getarea());
13+
}
14+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package inheritance;
2+
3+
public class retangle extends Class1 {
4+
int getarea() {
5+
return 10;
6+
}
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package inheritance;
2+
3+
public class square extends Class1 {
4+
int getarea() {
5+
return 0;
6+
}
7+
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package inheritance;
2+
3+
public class triangle extends Class1 {
4+
int getarea() {
5+
return 30;
6+
}
7+
}

inheritance/src/module-info.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
*
3+
*/
4+
/**
5+
*
6+
*/
7+
module inheritance {
8+
}

0 commit comments

Comments
 (0)