Loading...
Loading...
A dual-SIM phone has a Jio SIM and an Airtel SIM. Both SIM interfaces give a default network() and callRate(), so the phone class must decide which version to use.
Write interfaces Jio and Airtel, each with default String network() (Jio 5G / Airtel 4G) and default int callRate() (1 / 2 paise per second). DualSimPhone implements Jio, Airtel keeps the active SIM and overrides both methods with Jio.super... or Airtel.super....
use jio, use airtel, network or call s (s seconds).network prints the active network. call s prints Call s sec on NETWORK: c paise. use prints nothing. At the end print TOTAL c paise. The phone starts on Jio.Example
Input
5 network call 60 use airtel call 60 network
Output
Jio 5G Call 60 sec on Jio 5G: 60 paise Call 60 sec on Airtel 4G: 120 paise Airtel 4G TOTAL 180 paise
The same 60-second call costs 60 paise on Jio and 120 on Airtel.
Try the problem first. Open one hint at a time.
Without overriding network() and callRate(), the class does not compile: inherits unrelated defaults.
Inside the override, Jio.super.network() runs the Jio default; pick it with an if on the active SIM.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor