Multiple choice

Which of the following is the correct syntax to start an explicit activity?

  1. Intent intent = new Intent(MyActivity.this, MyOtherActivity); startActivity(intent);

  2. Intent intent = new Intent(MyActivity.this, MyOtherActivity.class); startActivity(intent);

  3. Intent intent = new Intent(MyActivity.class, MyOtherActivity.class); startActivity(intent);

  4. Intent intent = new Intent(this, MyOtherActivity.this); startActivity(intent);

  5. Intent intent = new Intent(MyOtherActivity.class); startActivity(intent);

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

After calling startActivity, the new activity, i.e. MyOtherActivity will be created and will move to the top of the activity stack.