-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathQuestion45.java
More file actions
34 lines (31 loc) · 895 Bytes
/
Question45.java
File metadata and controls
34 lines (31 loc) · 895 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
// Interface ShapeX is created
interface ShapeX {
public String baseX = "This is Shape1";
public void display1();
}
// Interface ShapeY is created which extends ShapeX
interface ShapeY extends ShapeX {
public String baseY = "This is Shape2";
public void display2();
}
// Class ShapeG is created which implements ShapeY
class ShapeG implements ShapeY {
public String baseG = "This is Shape3";
//Overriding method in ShapeX interface
public void display1() {
System.out.println("Circle: " + baseX);
}
// Override method in ShapeY interface
public void display2() {
System.out.print("Circle: " + baseY);
}
}
// Main class Question
public class Question45{
public static void main(String[] args) {
//Object of class shapeG is created and display methods are called.
ShapeG circle = new ShapeG();
circle.display1();
circle.display2();
}
}