Skip to content

Commit c10e194

Browse files
authored
Add files via upload
1 parent 07b9818 commit c10e194

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
interface ShapeX {
2+
public String base = "This is Shape1";
3+
public void display1();
4+
}
5+
6+
// Interface ShapeY is created which extends ShapeX
7+
interface ShapeY extends ShapeX {
8+
public String base = "This is Shape2";
9+
public void display2();
10+
}
11+
12+
// Class ShapeG is created which implements ShapeY
13+
class ShapeG implements ShapeY {
14+
public String base = "This is Shape3";
15+
//Overriding method in ShapeX interface
16+
17+
public void display1() {
18+
System.out.println("ShapeX: " + ShapeX.base);
19+
}
20+
// Override method in ShapeY interface
21+
public void display2(){
22+
System.out.println("ShapeY: " + ShapeY.base);
23+
}
24+
}
25+
26+
// Main class Question5
27+
public class Question5{
28+
public static void main(String[] args) {
29+
//Object of class shapeG is created and display methods are called.
30+
ShapeG circle = new ShapeG();
31+
circle.display1();
32+
circle.display2();
33+
}
34+
}

0 commit comments

Comments
 (0)