Android Application Development (AND-401) — Question 49
What does the following code achieve?
Intent intent = new Intent(FirstActivity.this, SecondActivity.class); startActivityForResult(intent);
Answer options
- A. Starts a browser activity
- B. Starts a sub-activity
- C. Starts an activity service
- D. Sends results to another activity.
Correct answer: B
Explanation
The correct answer is B, as the code snippet creates an Intent to start a new activity (SecondActivity) from the current activity (FirstActivity) and calls startActivityForResult, which is specifically used for starting sub-activities that can return results. The other options are incorrect because the code does not involve a browser (A), does not relate to an activity service (C), and does not inherently send results to another activity (D) without additional context.