Actually This is a question asked in interview.
I have five activities A,B,C,D and E in an android application. I open all the activities in their order as shown. Now I have to close odd activities on a button click. And this button exist in E activity.
I give one solution that I have static instance of all activities and from any activity we can close any one activity or other solution is that I can send instance of one activity to another activity by intent and in last activity we have instance of all previous activity. Now we can also close odd or even whatever activity it is.
But I think there may be some other options available which is best then above.