-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP48_InterfaceMultipleInheritance.java
More file actions
46 lines (37 loc) · 1.3 KB
/
Copy pathP48_InterfaceMultipleInheritance.java
File metadata and controls
46 lines (37 loc) · 1.3 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
package programs;
/**
* ============================================================
* PROGRAM 48: Multiple Inheritance with Interfaces
* ============================================================
* Problem: WAP to achieve multiple inheritance in Java
* by implementing multiple interfaces (`Printable` and `Scannable`)
* in a `MultifunctionPrinter` class.
* ============================================================
*/
interface Printable {
void printDocument(String document);
}
interface Scannable {
void scanDocument(String document);
}
class MultifunctionPrinter implements Printable, Scannable {
private String model;
public MultifunctionPrinter(String model) {
this.model = model;
}
@Override
public void printDocument(String document) {
System.out.println(" 🖨️ [" + model + "] Printing: " + document);
}
@Override
public void scanDocument(String document) {
System.out.println(" 📄 [" + model + "] Scanning: " + document);
}
}
public class P48_InterfaceMultipleInheritance {
public static void main(String[] args) {
MultifunctionPrinter mfp = new MultifunctionPrinter("HP LaserJet Pro 4000");
mfp.printDocument("Annual Financial Report.pdf");
mfp.scanDocument("Signed_Contract.png");
}
}