Multiple interface implementation
📖 Scenario: Imagine you are building a simple system where different devices can perform multiple actions. For example, a device might be able to print and scan documents. To organize this, you use interfaces to define these actions.
🎯 Goal: You will create two interfaces, Printer and Scanner, each with one method. Then, you will create a class MultiFunctionDevice that implements both interfaces. Finally, you will create an object of this class and call both methods.
📋 What You'll Learn
Create an interface called
Printer with a method printDocument().Create an interface called
Scanner with a method scanDocument().Create a class called
MultiFunctionDevice that implements both Printer and Scanner interfaces.Implement the methods
printDocument() and scanDocument() in the MultiFunctionDevice class.Create an object of
MultiFunctionDevice and call both printDocument() and scanDocument() methods.Print the outputs exactly as specified.
💡 Why This Matters
🌍 Real World
Many devices like printers, scanners, and fax machines support multiple functions. Using interfaces helps organize these capabilities clearly in code.
💼 Career
Understanding multiple interface implementation is important for designing flexible and maintainable code in object-oriented programming, a common requirement in software development jobs.
Progress0 / 4 steps