Design an ATM Machine — Concept Check
Questions on Design an ATM Machine. Model an ATM as a state machine with pluggable transaction commands and a validation chain, communicating with a remote BankServer.
Questions in this quiz
8 questions on Design an ATM Machine — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.An ATM is in the IdleState. What happens if a user tries to enter a PIN?
- AAn error is thrown because no card is inserted.
- BThe ATM ignores the PIN entry.
- CThe ATM moves to CardInsertedState without error.
- DThe ATM accepts the PIN and moves to PinEnteredState.
2.A user inserts a card and enters a correct PIN. What is the next valid action?
- ASelect a transaction.
- BEject the card.
- CInsert another card.
- DEnter the PIN again.
3.During a withdrawal transaction, what ensures the ATM dispenses the correct amount?
- AThe Command pattern in WithdrawalTransaction.
- BThe BankServer interface.
- CThe ATMState interface.
- DThe IdleState logic.
4.What happens if a card is inserted while the ATM is in TransactionInProgressState?
- AThe card is accepted and transaction is queued.
- BThe transaction is canceled and card is accepted.
- CThe ATM switches to CardInsertedState.
- DThe ATM throws an error due to ongoing transaction.
5.A user tries to withdraw more than their balance. Which validation step fails?
- ABalance sufficiency check.
- BDaily limit check.
- CPIN check.
- DCard validity check.
6.If a user selects a transaction before entering a PIN, what occurs?
- AThe ATM moves to TransactionInProgressState.
- BThe transaction proceeds without PIN.
- CAn error is thrown because PIN is required first.
- DThe ATM accepts the transaction but delays execution.
7.How does the ATM ensure extensibility for new transaction types?
- ABy changing the IdleState logic.
- BBy modifying the ATMState interface.
- CBy adding methods to the BankServer interface.
- DBy using the Command pattern for transactions.
8.Why might someone incorrectly assume the ATM can dispense cash before PIN entry?
- AThey believe the ATMState always allows cash dispensing.
- BThey assume the ATM skips validation steps.
- CThey think cash dispensing is independent of PIN validation.
- DThey think the Command pattern bypasses state checks.