Skip to content

Commit ef4e1f8

Browse files
authored
Merge pull request #18 from Ayush167/main
Sample.java
2 parents ced9b07 + 63fc7ba commit ef4e1f8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

simpleSingleInheritance.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
class Point2D
2+
{
3+
int x;
4+
int y;
5+
void display()
6+
{
7+
System.out.println("x="+x+"y="+y);
8+
}
9+
}
10+
class Point2D extends Point3D
11+
{
12+
int z;
13+
void display()
14+
{
15+
System.out.println("x="+x+"y="+y+"z="+z);
16+
}
17+
}
18+
class simpleSingleInheritance
19+
{
20+
public static void main(String args[])
21+
{
22+
Point2D P1 = new P1();
23+
Point3D P2 = new P2();
24+
P1.x = 10;
25+
P1.y = 20;
26+
System.out.println("Point2D P1 is" + P1.display());
27+
// initializing point3d
28+
P2.x = 5;
29+
P2.y = 6;
30+
P3.z = 15;
31+
System.out.println("Point3D P2 is" + P2.display());
32+
33+
}
34+
}
35+
36+
37+

0 commit comments

Comments
 (0)