File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments