Android Application Development (AND-401) — Question 96

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

Answer options

Correct answer: B

Explanation

The correct answer is B because the code specifies the toast's gravity as top-right, which means it will appear in that corner of the screen. Option A is incorrect as it misinterprets the placement of UI components rather than the toast itself. Option C is misleading because it implies the text message is positioned within the toast box, not the toast's overall position. Option D is wrong as it incorrectly states that the toast is centered at (0,0) instead of being in the top-right corner.