Android - Sample Interview Question (Senior Level)

Which potential problem/s does the following code have?

public class MainActivity extends AppCompatActivity {

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);

       new AsyncTask<Void, Void, Void>() {

           @Override
           protected Void doInBackground(Void... voids) {
               SystemClock.sleep(10000);
               return null;
           }

           @Override
           protected void onPostExecute(Void aVoid) {
               findViewById(R.id.view).setVisibility(View.VISIBLE);
               super.onPostExecute(aVoid);
           }
       };
   }
}

  1. Memory leak and/or an IllegalArgumentException
    exception can be thrown
  2. Freezing UI
  3. It is impossible to modify the UI state
    in the onPostExecute method
  4. The code is fine
Tests in Android for Seniors

Test Name Difficulty Time (minutes) No. of Questions
Android Online Test for Seniors Android Senior 60 30

More Specific Tests in Android for Seniors

Test Name Difficulty Time (Minutes) No. of Questions
Android-Performance Online Test for Seniors Android - Performance Senior 20 10
Android-Application-Components Online Test for Seniors Android - Application Components Senior 20 10
Android-User-Interface Online Test for Seniors Android - User Interface Senior 20 10