開発者は、Payment Processor インターフェイスで支払いに対して定義されている内容に準拠した小切手処理支払い機能を提供する CheckPaymentProcessor クラスを実装する必要があります。
PaymentProcessor インターフェース クラスを使用するにはどの実装が正しいですか?
正解:D
The correct implementation of theCheckPaymentProcessorclass must adhere to thePaymentProcessorinterface. To accomplish this:
* Use theimplementskeyword to signify that theCheckPaymentProcessorclass is implementing thePaymentProcessorinterface.
* Define thepaymethod in theCheckPaymentProcessorclass, as it is required by thePaymentProcessorinterface.
* Thepaymethod must match the method signature defined in thePaymentProcessorinterface (void pay (Decimal amount)).
Explanation of Option D:
* It usesimplements PaymentProcessorto correctly indicate that the class adheres to the interface.
* Thepaymethod is properly implemented with the required method signature and includes a placeholder for functional code.
Other Options:
* Option A: Thepaymethod is not implemented correctly (no method body).
* Option B: Incorrect use ofextendsinstead ofimplements(interfaces are implemented, not extended).
* Option C: Same issue as Option B, with a slight variation in formatting.
最新のコメント (最新のコメントはトップにあります。)
Cだと思う