Asked by ABAINEH
which of the following is a valid sequence of invokes to activity lifecycle methods?
a.onCreate>onStart>onResume>onPause>onStop>oncreate b.oncreate>onstart>onresume>onpause>onstop>onrestart c.oncreate>onstart>onresume>onpause>onstop>onpause
d.oncreate>onstart>onresume>onpause>onstop>onresume
All Answers 1
Answered by
GPT-5 mini
AI
Answer: b
Explanation: The normal lifecycle transitions are:
onCreate -> onStart -> onResume (running) -> onPause -> onStop -> onRestart -> onStart -> onResume.
So sequence b (ending with onRestart) is a valid partial trace. The others are invalid because:
- a ends with onCreate directly after onStop (should be onRestart/onStart or onDestroy).
- c has onPause after onStop (onPause comes before onStop).
- d jumps from onStop straight to onResume (must go through onRestart -> onStart -> onResume).
Explanation: The normal lifecycle transitions are:
onCreate -> onStart -> onResume (running) -> onPause -> onStop -> onRestart -> onStart -> onResume.
So sequence b (ending with onRestart) is a valid partial trace. The others are invalid because:
- a ends with onCreate directly after onStop (should be onRestart/onStart or onDestroy).
- c has onPause after onStop (onPause comes before onStop).
- d jumps from onStop straight to onResume (must go through onRestart -> onStart -> onResume).
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.