Android implementation of one of appsopt exam questions