A stack operates on the Last In, First Out (LIFO) principle, where the most recently added element is the first to be retrieved. Examining the sequence of operations:
1. PUSH(10): Stack: [10]
2. PUSH(20): Stack: [10, 20]
3. POP(): Removes 20. Stack: [10]
4. POP(): Removes 10. Stack: []
5. PUSH(30): Stack: [30]
6. PUSH(40): Stack: [30, 40]
7. POP(): Removes 40. Stack: [30]
8. POP(): Removes 30. Stack: []
The elements removed from the stack, in order, are 20, 10, 40, 30. Corresponding to the provided options, the correct sequence is (B), (A), (D), (C).