nerdexam
Android

AND-401 · Question #102

What does the following line of code do? Toast toast = Toast.makeText(this,"Android ATC", Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP|Gravity.RIGH, 0, 0);

The correct answer is B. The toast will appear on the top-right corner. See the full explanation below for the reasoning.

Question

What does the following line of code do? Toast toast = Toast.makeText(this,"Android ATC", Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP|Gravity.RIGH, 0, 0);

Options

  • AThe toast will have it UI components place on the top-right corner.
  • BThe toast will appear on the top-right corner.
  • CThe toast will show the text message on top-right corner of the toast box.
  • DThe toast will appear at the center of the screen at position (0,0), but aligned to the top- right

How the community answered

(30 responses)
  • A
    17% (5)
  • B
    70% (21)
  • C
    7% (2)
  • D
    7% (2)

Community Discussion

No community discussion yet for this question.

Full AND-401 Practice